2 |
- |
1 |
#define _LOCK_EXTENSION
|
|
|
2 |
#define _QLOCK_EXTENSION
|
|
|
3 |
#define _BSD_EXTENSION
|
|
|
4 |
#include <sys/types.h>
|
|
|
5 |
#include <lock.h>
|
|
|
6 |
#include <qlock.h>
|
|
|
7 |
#include <lib9.h>
|
|
|
8 |
#include <stdlib.h>
|
|
|
9 |
#include <string.h>
|
|
|
10 |
#include <bsd.h>
|
|
|
11 |
#include <unistd.h>
|
|
|
12 |
#include <fcntl.h>
|
|
|
13 |
#include <assert.h>
|
|
|
14 |
#include <utf.h>
|
|
|
15 |
#include <fmt.h>
|
|
|
16 |
#include <signal.h>
|
|
|
17 |
|
|
|
18 |
typedef
|
|
|
19 |
struct Qid
|
|
|
20 |
{
|
|
|
21 |
uvlong path;
|
|
|
22 |
ulong vers;
|
|
|
23 |
uchar type;
|
|
|
24 |
} Qid;
|
|
|
25 |
|
|
|
26 |
typedef
|
|
|
27 |
struct Dir {
|
|
|
28 |
/* system-modified data */
|
|
|
29 |
ushort type; /* server type */
|
|
|
30 |
uint dev; /* server subtype */
|
|
|
31 |
/* file data */
|
|
|
32 |
Qid qid; /* unique id from server */
|
|
|
33 |
ulong mode; /* permissions */
|
|
|
34 |
ulong atime; /* last read time */
|
|
|
35 |
ulong mtime; /* last write time */
|
|
|
36 |
vlong length; /* file length: see <u.h> */
|
|
|
37 |
char *name; /* last element of path */
|
|
|
38 |
char *uid; /* owner name */
|
|
|
39 |
char *gid; /* group name */
|
|
|
40 |
char *muid; /* last modifier name */
|
|
|
41 |
} Dir;
|
|
|
42 |
|
|
|
43 |
uint _convM2D(uchar*, uint, Dir*, char*);
|
|
|
44 |
uint _convD2M(Dir*, uchar*, uint);
|
|
|
45 |
Dir *_dirstat(char*);
|
|
|
46 |
int _dirwstat(char*, Dir*);
|
|
|
47 |
Dir *_dirfstat(int);
|
|
|
48 |
int _dirfwstat(int, Dir*);
|
|
|
49 |
long _dirread(int, Dir**);
|
|
|
50 |
long _dirreadall(int, Dir**);
|
|
|
51 |
void _nulldir(Dir*);
|
|
|
52 |
uint _sizeD2M(Dir*);
|
|
|
53 |
|
|
|
54 |
typedef
|
|
|
55 |
struct Waitmsg
|
|
|
56 |
{
|
|
|
57 |
int pid; /* of loved one */
|
|
|
58 |
unsigned long time[3]; /* of loved one & descendants */
|
|
|
59 |
char *msg;
|
|
|
60 |
} Waitmsg;
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
extern int _AWAIT(char*, int);
|
|
|
64 |
extern int _ALARM(unsigned long);
|
|
|
65 |
extern int _BIND(const char*, const char*, int);
|
|
|
66 |
extern int _CHDIR(const char*);
|
|
|
67 |
extern int _CLOSE(int);
|
|
|
68 |
extern int _CREATE(char*, int, unsigned long);
|
|
|
69 |
extern int _DUP(int, int);
|
|
|
70 |
extern int _ERRSTR(char*, unsigned int);
|
|
|
71 |
extern int _EXEC(char*, char*[]);
|
|
|
72 |
extern void _EXITS(char *);
|
|
|
73 |
extern int _FD2PATH(int, char*, int);
|
|
|
74 |
extern int _FAUTH(int, char*);
|
|
|
75 |
extern int _FSESSION(int, char*, int);
|
|
|
76 |
extern int _FSTAT(int, unsigned char*, int);
|
|
|
77 |
extern int _FWSTAT(int, unsigned char*, int);
|
|
|
78 |
extern int _MOUNT(int, int, const char*, int, const char*);
|
|
|
79 |
extern int _NOTED(int);
|
|
|
80 |
extern int _NOTIFY(int(*)(void*, char*));
|
|
|
81 |
extern int _OPEN(const char*, int);
|
|
|
82 |
extern int _PIPE(int*);
|
|
|
83 |
extern long _PREAD(int, void*, long, long long);
|
|
|
84 |
extern long _PWRITE(int, void*, long, long long);
|
|
|
85 |
extern long _READ(int, void*, long);
|
|
|
86 |
extern int _REMOVE(const char*);
|
|
|
87 |
extern int _RENDEZVOUS(unsigned long, unsigned long);
|
|
|
88 |
extern int _RFORK(int);
|
|
|
89 |
extern int _SEGATTACH(int, char*, void*, unsigned long);
|
|
|
90 |
extern int _SEGBRK(void*, void*);
|
|
|
91 |
extern int _SEGDETACH(void*);
|
|
|
92 |
extern int _SEGFLUSH(void*, unsigned long);
|
|
|
93 |
extern int _SEGFREE(void*, unsigned long);
|
|
|
94 |
extern long long _SEEK(int, long long, int);
|
|
|
95 |
extern int _SLEEP(long);
|
|
|
96 |
extern int _STAT(const char*, unsigned char*, int);
|
|
|
97 |
extern Waitmsg* _WAIT(void);
|
|
|
98 |
extern long _WRITE(int, const void*, long);
|
|
|
99 |
extern int _WSTAT(const char*, unsigned char*, int);
|
|
|
100 |
extern void *_MALLOCZ(int, int);
|
|
|
101 |
extern int _WERRSTR(char*, ...);
|
|
|
102 |
extern long _READN(int, void*, long);
|
|
|
103 |
extern int _IOUNIT(int);
|
|
|
104 |
|
|
|
105 |
#define dirstat _dirstat
|
|
|
106 |
#define dirfstat _dirfstat
|
|
|
107 |
|
|
|
108 |
#define OREAD 0
|
|
|
109 |
#define OWRITE 1
|
|
|
110 |
#define ORDWR 2
|
|
|
111 |
#define OCEXEC 32
|
|
|
112 |
|
|
|
113 |
#define AREAD 4
|
|
|
114 |
#define AWRITE 2
|
|
|
115 |
#define AEXEC 1
|
|
|
116 |
#define AEXIST 0
|
|
|
117 |
|
|
|
118 |
#define open _OPEN
|
|
|
119 |
#define close _CLOSE
|
|
|
120 |
#define read _READ
|
|
|
121 |
#define write _WRITE
|
|
|
122 |
#define _exits(s) _exit(s && *(char*)s ? 1 : 0)
|
|
|
123 |
#define exits(s) exit(s && *(char*)s ? 1 : 0)
|
|
|
124 |
#define create _CREATE
|
|
|
125 |
#define pread _PREAD
|
|
|
126 |
#define readn _READN
|
|
|
127 |
#define mallocz _MALLOCZ
|
|
|
128 |
#define iounit _IOUNIT
|
|
|
129 |
#define bind _BIND
|
|
|
130 |
|
|
|
131 |
/* assume being called as in event.c */
|
|
|
132 |
#define postnote(x, pid, msg) kill(pid, SIGTERM)
|
|
|
133 |
#define atnotify(x, y) signal(SIGTERM, ekill)
|
|
|
134 |
|
|
|
135 |
#define ERRMAX 128
|
|
|
136 |
|
|
|
137 |
extern void setmalloctag(void*, ulong);
|
|
|
138 |
extern ulong getcallerpc(void*);
|