kernel&all: create() syscall only sends Tcreate
In Plan9 the create syscall fallback on a open(OTRUNC) if the path provided already exists. This is actually a common requirement as most programs (editors, cat...) simply requires that a file is there and is empty, and doesn't care overwriting existing contents (note that this is particularily sensible with something like fossil). In Jehanne the application is responsible of actually handle this "file exists" error but libc provides ocreate() to mimic the Plan9 behaviour. Note that ocreate introduce a subtle race too: the path is walked several times if the file exists, thus it could misbehave on concurrent namespace changes. However I guess this is not going to happen often enough to care now. NOTE we will probably address this rare race too, with a more drammatic change to syscalls: a new walk() syscall that will provide an unopen fd.
This commit is contained in:
@ -28,7 +28,7 @@ main(void)
|
|||||||
static Rune r[16] = L"Ciao Mondo!";
|
static Rune r[16] = L"Ciao Mondo!";
|
||||||
static Rune buf[16];
|
static Rune buf[16];
|
||||||
|
|
||||||
if((fd = create("/tmp/runetest.txt", OWRITE, 0666L)) < 0) {
|
if((fd = ocreate("/tmp/runetest.txt", OWRITE, 0666L)) < 0) {
|
||||||
print("FAIL: open: %r\n");
|
print("FAIL: open: %r\n");
|
||||||
exits("FAIL");
|
exits("FAIL");
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ fdfork(int fd, int post)
|
|||||||
pipe(ch);
|
pipe(ch);
|
||||||
|
|
||||||
len = snprint(path, sizeof path, "hcube.%d.%d", getpid(), seq++);
|
len = snprint(path, sizeof path, "hcube.%d.%d", getpid(), seq++);
|
||||||
pfd = create(path, OWRITE|ORCLOSE, 0666);
|
pfd = ocreate(path, OWRITE|ORCLOSE, 0666);
|
||||||
if(pfd == -1)
|
if(pfd == -1)
|
||||||
sysfatal("fdfork: create: %r");
|
sysfatal("fdfork: create: %r");
|
||||||
snprint(buf, sizeof buf, "%d", ch[0]);
|
snprint(buf, sizeof buf, "%d", ch[0]);
|
||||||
|
@ -20,10 +20,11 @@
|
|||||||
#define NP_ORDWR 2 /* read and write */
|
#define NP_ORDWR 2 /* read and write */
|
||||||
#define NP_OEXEC 3 /* execute, == read but check execute permission */
|
#define NP_OEXEC 3 /* execute, == read but check execute permission */
|
||||||
#define NP_OTRUNC 16 /* or'ed in (except for exec), truncate file first */
|
#define NP_OTRUNC 16 /* or'ed in (except for exec), truncate file first */
|
||||||
|
#define NP_OCEXEC 32 /* or'ed in, close on exec */
|
||||||
#define NP_ORCLOSE 64 /* or'ed in, remove on close */
|
#define NP_ORCLOSE 64 /* or'ed in, remove on close */
|
||||||
|
|
||||||
/* bits that must be zero in open/create mode */
|
/* bits that must be zero in open/create mode */
|
||||||
#define NP_OZEROES ~(NP_OREAD|NP_OWRITE|NP_ORDWR|NP_OEXEC|NP_OTRUNC|NP_ORCLOSE)
|
#define NP_OZEROES ~(NP_OREAD|NP_OWRITE|NP_ORDWR|NP_OEXEC|NP_OTRUNC|NP_OCEXEC|NP_ORCLOSE)
|
||||||
|
|
||||||
typedef enum NinepMsgType
|
typedef enum NinepMsgType
|
||||||
{
|
{
|
||||||
|
@ -396,6 +396,7 @@ extern void longjmp(jmp_buf, int);
|
|||||||
extern char* mktemp(char*);
|
extern char* mktemp(char*);
|
||||||
extern double modf(double, double*);
|
extern double modf(double, double*);
|
||||||
extern void notejmp(void*, jmp_buf, int);
|
extern void notejmp(void*, jmp_buf, int);
|
||||||
|
extern int ocreate(const char* path, unsigned int omode, unsigned int perm);
|
||||||
extern void perror(const char*);
|
extern void perror(const char*);
|
||||||
extern int pipe(int pipes[2]);
|
extern int pipe(int pipes[2]);
|
||||||
extern int postnote(int, int, const char *);
|
extern int postnote(int, int, const char *);
|
||||||
@ -565,14 +566,12 @@ extern void freenetconninfo(NetConnInfo*);
|
|||||||
|
|
||||||
/* Open modes: Popular flags among filesystems */
|
/* Open modes: Popular flags among filesystems */
|
||||||
#define OTRUNC 0x0100 /* or'ed in (except for exec), truncate file first */
|
#define OTRUNC 0x0100 /* or'ed in (except for exec), truncate file first */
|
||||||
#define OEXCL 0x0200 /* or'ed in, exclusive create */
|
|
||||||
|
|
||||||
/* Access modes */
|
/* Access modes */
|
||||||
#define AEXIST OSTAT /* accessible: exists */
|
#define AEXIST 0 /* accessible: exists */
|
||||||
#define AREAD OREAD /* read access */
|
#define AREAD 4 /* read access */
|
||||||
#define AWRITE OWRITE /* write access */
|
#define AWRITE 2 /* write access */
|
||||||
#define AEXEC OEXEC /* execute access */
|
#define AEXEC 1 /* execute access */
|
||||||
#define AMASK (OSTAT|OREAD|OWRITE|OEXEC)
|
|
||||||
|
|
||||||
/* Segattch */
|
/* Segattch */
|
||||||
#define SG_RONLY 0040 /* read only */
|
#define SG_RONLY 0040 /* read only */
|
||||||
@ -654,58 +653,23 @@ struct Waitmsg
|
|||||||
char *msg;
|
char *msg;
|
||||||
} Waitmsg;
|
} Waitmsg;
|
||||||
|
|
||||||
//extern void _exits(const char*) __attribute__ ((noreturn));
|
|
||||||
|
|
||||||
extern int access(const char*, int);
|
extern int access(const char*, int);
|
||||||
//extern int64_t alarm(uint64_t);
|
|
||||||
//extern int await(char*, int);
|
|
||||||
//extern int64_t awake(int64_t);
|
|
||||||
extern int awakened(int64_t);
|
extern int awakened(int64_t);
|
||||||
//extern int bind(const char*, const char*, int);
|
|
||||||
extern int brk(void*);
|
extern int brk(void*);
|
||||||
//extern int chdir(const char*);
|
|
||||||
//extern int close(int);
|
|
||||||
//extern int create(const char*, int, uint32_t);
|
|
||||||
//extern int dup(int, int);
|
|
||||||
//extern int errstr(char*, uint32_t);
|
|
||||||
//extern int exec(const char*, char* const[]);
|
|
||||||
extern int execl(const char*, ...);
|
extern int execl(const char*, ...);
|
||||||
extern int forgivewkp(int64_t);
|
extern int forgivewkp(int64_t);
|
||||||
extern pid_t fork(void);
|
extern pid_t fork(void);
|
||||||
//extern pid_t rfork(int);
|
|
||||||
//extern int fauth(int, const char*);
|
|
||||||
//extern int fstat(int, uint8_t*, int);
|
|
||||||
//extern int fwstat(int, uint8_t*, int);
|
|
||||||
//extern int fversion(int, int, char*, int);
|
|
||||||
//extern int mount(int, int, const char*, int, const char*, int);
|
|
||||||
//extern int unmount(const char*, const char*);
|
|
||||||
//extern int noted(int);
|
|
||||||
//extern int notify(void(*)(void*, char*));
|
|
||||||
//extern int open(const char*, int);
|
|
||||||
//extern int fd2path(int, char*, int);
|
|
||||||
// extern int fdflush(int);
|
|
||||||
//extern int pipe(int*);
|
|
||||||
//extern int32_t pread(int, void*, int32_t, int64_t);
|
|
||||||
//extern int32_t pwrite(int, const void*, int32_t, int64_t);
|
|
||||||
//extern int32_t read(int, void*, int32_t);
|
|
||||||
extern int32_t readn(int, void*, int32_t);
|
extern int32_t readn(int, void*, int32_t);
|
||||||
//extern int remove(const char*);
|
|
||||||
extern void* sbrk(uint32_t);
|
extern void* sbrk(uint32_t);
|
||||||
extern int32_t oseek(int, int32_t, int);
|
extern int32_t oseek(int, int32_t, int);
|
||||||
//extern int64_t seek(int, int64_t, int);
|
|
||||||
extern void* segattach(int, const char*, void*, unsigned long);
|
extern void* segattach(int, const char*, void*, unsigned long);
|
||||||
extern int segdetach(void*);
|
extern int segdetach(void*);
|
||||||
extern int segfree(void*, unsigned long);
|
extern int segfree(void*, unsigned long);
|
||||||
//extern int semacquire(int32_t*, int);
|
|
||||||
//extern int32_t semrelease(int32_t*, int32_t);
|
|
||||||
extern void sleep(int32_t);
|
extern void sleep(int32_t);
|
||||||
extern int stat(const char*, uint8_t*, int);
|
extern int stat(const char*, uint8_t*, int);
|
||||||
//extern int tsemacquire(int32_t*, uint64_t);
|
|
||||||
extern Waitmsg* wait(void);
|
extern Waitmsg* wait(void);
|
||||||
extern int waitpid(void);
|
extern int waitpid(void);
|
||||||
//extern int32_t write(int, const void*, int32_t);
|
|
||||||
extern int wstat(const char*, uint8_t*, int);
|
extern int wstat(const char*, uint8_t*, int);
|
||||||
//extern void* rendezvous(void*, void*);
|
|
||||||
|
|
||||||
extern Dir* dirstat(const char*);
|
extern Dir* dirstat(const char*);
|
||||||
extern Dir* dirfstat(int);
|
extern Dir* dirfstat(int);
|
||||||
|
@ -334,10 +334,10 @@ acmeerrorinit(void)
|
|||||||
if(pipe(pfd) < 0)
|
if(pipe(pfd) < 0)
|
||||||
error("can't create pipe");
|
error("can't create pipe");
|
||||||
sprint(acmeerrorfile, "/srv/acme.%s.%d", getuser(), mainpid);
|
sprint(acmeerrorfile, "/srv/acme.%s.%d", getuser(), mainpid);
|
||||||
fd = create(acmeerrorfile, OWRITE, 0666);
|
fd = ocreate(acmeerrorfile, OWRITE, 0666);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
remove(acmeerrorfile);
|
remove(acmeerrorfile);
|
||||||
fd = create(acmeerrorfile, OWRITE, 0666);
|
fd = ocreate(acmeerrorfile, OWRITE, 0666);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
error("can't create acmeerror file");
|
error("can't create acmeerror file");
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ tempfile(void)
|
|||||||
buf[5] = i;
|
buf[5] = i;
|
||||||
if(access(buf, AEXIST) == 0)
|
if(access(buf, AEXIST) == 0)
|
||||||
continue;
|
continue;
|
||||||
fd = create(buf, ORDWR|ORCLOSE|OCEXEC, 0600);
|
fd = ocreate(buf, ORDWR|ORCLOSE|OCEXEC, 0600);
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +594,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
|
|||||||
goto Rescue1;
|
goto Rescue1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fd = create(name, OWRITE, 0666);
|
fd = ocreate(name, OWRITE, 0666);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
warning(nil, "can't create file %s: %r\n", name);
|
warning(nil, "can't create file %s: %r\n", name);
|
||||||
goto Rescue1;
|
goto Rescue1;
|
||||||
@ -1379,7 +1379,7 @@ Hard:
|
|||||||
n += i;
|
n += i;
|
||||||
memmove(buf+n, "/cmd", 5);
|
memmove(buf+n, "/cmd", 5);
|
||||||
n += 5;
|
n += 5;
|
||||||
fd = create("/env/path", OWRITE, 0666);
|
fd = ocreate("/env/path", OWRITE, 0666);
|
||||||
write(fd, buf, n);
|
write(fd, buf, n);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -548,7 +548,7 @@ fsysopen(Xfid *x, Fid *f)
|
|||||||
int m;
|
int m;
|
||||||
|
|
||||||
/* can't truncate anything, so just disregard */
|
/* can't truncate anything, so just disregard */
|
||||||
x->mode &= ~(NP_OTRUNC);
|
x->mode &= ~(NP_OTRUNC|NP_OCEXEC);
|
||||||
/* can't execute or remove anything */
|
/* can't execute or remove anything */
|
||||||
if(x->mode==NP_OEXEC || (x->mode&NP_ORCLOSE))
|
if(x->mode==NP_OEXEC || (x->mode&NP_ORCLOSE))
|
||||||
goto Deny;
|
goto Deny;
|
||||||
|
@ -322,7 +322,7 @@ rowdump(Row *row, char *file)
|
|||||||
sprint(buf, "%s/acme.dump", home);
|
sprint(buf, "%s/acme.dump", home);
|
||||||
file = buf;
|
file = buf;
|
||||||
}
|
}
|
||||||
fd = create(file, OWRITE, 0600);
|
fd = ocreate(file, OWRITE, 0600);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
warning(nil, "can't open %s: %r\n", file);
|
warning(nil, "can't open %s: %r\n", file);
|
||||||
goto Rescue;
|
goto Rescue;
|
||||||
@ -666,7 +666,7 @@ rowload(Row *row, char *file, int initing)
|
|||||||
if(ndumped >= 0){
|
if(ndumped >= 0){
|
||||||
/* simplest thing is to put it in a file and load that */
|
/* simplest thing is to put it in a file and load that */
|
||||||
sprint(buf, "/tmp/d%d.%.4sacme", getpid(), getuser());
|
sprint(buf, "/tmp/d%d.%.4sacme", getpid(), getuser());
|
||||||
fd = create(buf, OWRITE|ORCLOSE, 0600);
|
fd = ocreate(buf, OWRITE|ORCLOSE, 0600);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
free(r);
|
free(r);
|
||||||
warning(nil, "can't create temp file: %r\n");
|
warning(nil, "can't create temp file: %r\n");
|
||||||
|
@ -78,11 +78,11 @@ int
|
|||||||
sleepuntil(uint32_t tm)
|
sleepuntil(uint32_t tm)
|
||||||
{
|
{
|
||||||
uint32_t now = time(0);
|
uint32_t now = time(0);
|
||||||
|
|
||||||
if (now < tm) {
|
if (now < tm) {
|
||||||
sleep((tm - now)*1000);
|
sleep((tm - now)*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ fatal(char *fmt, ...)
|
|||||||
static int
|
static int
|
||||||
openlock(char *file)
|
openlock(char *file)
|
||||||
{
|
{
|
||||||
return create(file, ORDWR, 0600);
|
return ocreate(file, ORDWR, 0600);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -258,7 +258,7 @@ createuser(void)
|
|||||||
dirfwstat(fd, &d);
|
dirfwstat(fd, &d);
|
||||||
close(fd);
|
close(fd);
|
||||||
snprint(file, sizeof file, "/cron/%s/cron", user);
|
snprint(file, sizeof file, "/cron/%s/cron", user);
|
||||||
fd = create(file, OREAD, 0644);
|
fd = ocreate(file, OREAD, 0644);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
fatal("couldn't create %s: %r", file);
|
fatal("couldn't create %s: %r", file);
|
||||||
nulldir(&d);
|
nulldir(&d);
|
||||||
@ -626,7 +626,7 @@ initcap(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a change uid capability
|
* create a change uid capability
|
||||||
*/
|
*/
|
||||||
char*
|
char*
|
||||||
mkcap(char *from, char *to)
|
mkcap(char *from, char *to)
|
||||||
|
@ -770,7 +770,7 @@ writeusers(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* write file */
|
/* write file */
|
||||||
fd = create(userkeys, OWRITE, 0660);
|
fd = ocreate(userkeys, OWRITE, 0660);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
free(buf);
|
free(buf);
|
||||||
fprint(2, "keyfs: can't write keys file\n");
|
fprint(2, "keyfs: can't write keys file\n");
|
||||||
|
@ -13,7 +13,7 @@ wrbio(char *file, Acctbio *a)
|
|||||||
|
|
||||||
fd = open(file, OWRITE);
|
fd = open(file, OWRITE);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
fd = create(file, OWRITE, 0660);
|
fd = ocreate(file, OWRITE, 0660);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
error("can't create %s", file);
|
error("can't create %s", file);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ setenv(char *var, char *val)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = create(var, OWRITE, 0644);
|
fd = ocreate(var, OWRITE, 0644);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
print("init: can't open %s\n", var);
|
print("init: can't open %s\n", var);
|
||||||
else{
|
else{
|
||||||
|
@ -86,7 +86,7 @@ getfile(SConn *conn, char *gf, uint8_t **buf, uint32_t *buflen, uint8_t *key, in
|
|||||||
* conn is already encrypted against wiretappers, but gf is also
|
* conn is already encrypted against wiretappers, but gf is also
|
||||||
* encrypted against server breakin.
|
* encrypted against server breakin.
|
||||||
*/
|
*/
|
||||||
if(buf == nil && (fd = create(gf, OWRITE, 0600)) < 0){
|
if(buf == nil && (fd = ocreate(gf, OWRITE, 0600)) < 0){
|
||||||
fprint(2, "secstore: can't open %s: %r\n", gf);
|
fprint(2, "secstore: can't open %s: %r\n", gf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ putfile(SConn *conn, char *id, char *pf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprint(s, Maxmsg, "%s/store/%s/%s", SECSTORE_DIR, id, pf);
|
snprint(s, Maxmsg, "%s/store/%s/%s", SECSTORE_DIR, id, pf);
|
||||||
pd = create(s, OWRITE, 0660);
|
pd = ocreate(s, OWRITE, 0660);
|
||||||
if(pd < 0){
|
if(pd < 0){
|
||||||
syslog(0, LOG, "can't open %s: %r", s);
|
syslog(0, LOG, "can't open %s: %r", s);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -18,7 +18,7 @@ ensure_exists(char *f, uint32_t perm)
|
|||||||
return;
|
return;
|
||||||
if(verbose)
|
if(verbose)
|
||||||
fprint(2,"first time setup for secstore: create %s %lo\n", f, perm);
|
fprint(2,"first time setup for secstore: create %s %lo\n", f, perm);
|
||||||
fd = create(f, OREAD, perm);
|
fd = ocreate(f, OREAD, perm);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
sysfatal("unable to create %s: %r", f);
|
sysfatal("unable to create %s: %r", f);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -125,7 +125,7 @@ copy(char *from, char *to, int todir)
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fdt=create(to, OWRITE, mode);
|
fdt=ocreate(to, OWRITE, mode);
|
||||||
if(fdt<0){
|
if(fdt<0){
|
||||||
fprint(2, "cp: can't create %s: %r\n", to);
|
fprint(2, "cp: can't create %s: %r\n", to);
|
||||||
close(fdf);
|
close(fdf);
|
||||||
@ -145,7 +145,7 @@ copy(char *from, char *to, int todir)
|
|||||||
dirt.gid = dirb->gid;
|
dirt.gid = dirb->gid;
|
||||||
if(dirfwstat(fdt, &dirt) < 0)
|
if(dirfwstat(fdt, &dirt) < 0)
|
||||||
fprint(2, "cp: warning: can't wstat %s: %r\n", to);
|
fprint(2, "cp: warning: can't wstat %s: %r\n", to);
|
||||||
}
|
}
|
||||||
free(dirb);
|
free(dirb);
|
||||||
close(fdf);
|
close(fdf);
|
||||||
close(fdt);
|
close(fdt);
|
||||||
|
@ -216,7 +216,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if(ofile){
|
if(ofile){
|
||||||
if(dotrunc)
|
if(dotrunc)
|
||||||
obf = create(ofile, OWRITE, 0664);
|
obf = ocreate(ofile, OWRITE, 0664);
|
||||||
else
|
else
|
||||||
obf = open(ofile, OWRITE);
|
obf = open(ofile, OWRITE);
|
||||||
if(obf < 0) {
|
if(obf < 0) {
|
||||||
|
@ -262,7 +262,7 @@ main(int argc, char **argv)
|
|||||||
disk = opendisk(argv[0], 0, 0);
|
disk = opendisk(argv[0], 0, 0);
|
||||||
if(disk == nil) {
|
if(disk == nil) {
|
||||||
if(fflag) {
|
if(fflag) {
|
||||||
if((fd = create(argv[0], ORDWR, 0666)) >= 0) {
|
if((fd = ocreate(argv[0], ORDWR, 0666)) >= 0) {
|
||||||
file = argv[0];
|
file = argv[0];
|
||||||
close(fd);
|
close(fd);
|
||||||
disk = opendisk(argv[0], 0, 0);
|
disk = opendisk(argv[0], 0, 0);
|
||||||
@ -334,7 +334,7 @@ sanitycheck(Disk *disk)
|
|||||||
bad = 0;
|
bad = 0;
|
||||||
if(dos && nresrv < 2 && seek(disk->fd, disk->secsize, 0) == disk->secsize
|
if(dos && nresrv < 2 && seek(disk->fd, disk->secsize, 0) == disk->secsize
|
||||||
&& read(disk->fd, buf, sizeof(buf)) >= 5 && strncmp(buf, "part ", 5) == 0) {
|
&& read(disk->fd, buf, sizeof(buf)) >= 5 && strncmp(buf, "part ", 5) == 0) {
|
||||||
fprint(2,
|
fprint(2,
|
||||||
"there's a plan9 partition on the disk\n"
|
"there's a plan9 partition on the disk\n"
|
||||||
"and you didn't specify -r 2 (or greater).\n"
|
"and you didn't specify -r 2 (or greater).\n"
|
||||||
"either specify -r 2 or -x to disable this check.\n");
|
"either specify -r 2 or -x to disable this check.\n");
|
||||||
@ -370,9 +370,9 @@ getdriveno(Disk *disk)
|
|||||||
return 0x80;
|
return 0x80;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The name is of the format #SsdC0/foo
|
* The name is of the format #SsdC0/foo
|
||||||
* or /dev/sdC0/foo.
|
* or /dev/sdC0/foo.
|
||||||
* So that we can just look for /sdC0, turn
|
* So that we can just look for /sdC0, turn
|
||||||
* #SsdC0/foo into #/sdC0/foo.
|
* #SsdC0/foo into #/sdC0/foo.
|
||||||
*/
|
*/
|
||||||
if(buf[0] == '#' && buf[1] == 'S')
|
if(buf[0] == '#' && buf[1] == 'S')
|
||||||
@ -382,7 +382,7 @@ getdriveno(Disk *disk)
|
|||||||
if(p[0] == 's' && p[1] == 'd' && (p[2]=='C' || p[2]=='D') &&
|
if(p[0] == 's' && p[1] == 'd' && (p[2]=='C' || p[2]=='D') &&
|
||||||
(p[3]=='0' || p[3]=='1'))
|
(p[3]=='0' || p[3]=='1'))
|
||||||
return 0x80 + (p[2]-'C')*2 + (p[3]-'0');
|
return 0x80 + (p[2]-'C')*2 + (p[3]-'0');
|
||||||
|
|
||||||
return 0x80;
|
return 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +496,7 @@ dosfs(int dofat, int dopbs, Disk *disk, char *label, int argc, char *argv[], int
|
|||||||
b->magic[1] = 0x3C;
|
b->magic[1] = 0x3C;
|
||||||
b->magic[2] = 0x90;
|
b->magic[2] = 0x90;
|
||||||
memmove(b->version, "Plan9.00", sizeof(b->version));
|
memmove(b->version, "Plan9.00", sizeof(b->version));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add bootstrapping code; offset is
|
* Add bootstrapping code; offset is
|
||||||
* determined from short jump (0xEB 0x??)
|
* determined from short jump (0xEB 0x??)
|
||||||
@ -550,7 +550,7 @@ if(chatty) print("clustersize %d\n", clustersize);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* the number of fat bits depends on how much disk is left
|
* the number of fat bits depends on how much disk is left
|
||||||
* over after you subtract out the space taken up by the fat tables.
|
* over after you subtract out the space taken up by the fat tables.
|
||||||
* try both. what a crock.
|
* try both. what a crock.
|
||||||
*/
|
*/
|
||||||
fatbits = 12;
|
fatbits = 12;
|
||||||
@ -589,7 +589,7 @@ Tryagain:
|
|||||||
clusters, newclusters);
|
clusters, newclusters);
|
||||||
if(chatty) print("clusters %d\n", clusters);
|
if(chatty) print("clusters %d\n", clusters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chatty) print("try %d fatbits => %d clusters of %d\n", fatbits, clusters, clustersize);
|
if(chatty) print("try %d fatbits => %d clusters of %d\n", fatbits, clusters, clustersize);
|
||||||
switch(fatbits){
|
switch(fatbits){
|
||||||
case 12:
|
case 12:
|
||||||
@ -621,7 +621,7 @@ if(chatty) print("try %d fatbits => %d clusters of %d\n", fatbits, clusters, clu
|
|||||||
PUTSHORT(b->nheads, t->heads);
|
PUTSHORT(b->nheads, t->heads);
|
||||||
PUTLONG(b->nhidden, disk->offset);
|
PUTLONG(b->nhidden, disk->offset);
|
||||||
PUTLONG(b->bigvolsize, volsecs);
|
PUTLONG(b->bigvolsize, volsecs);
|
||||||
|
|
||||||
sprint(r, "FAT%d ", fatbits);
|
sprint(r, "FAT%d ", fatbits);
|
||||||
if(fatbits == 32){
|
if(fatbits == 32){
|
||||||
Dosboot32 *bb;
|
Dosboot32 *bb;
|
||||||
@ -714,7 +714,7 @@ if(chatty) print("files @%lluX\n", seek(disk->wfd, 0LL, 1));
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Now positioned at the Files Area.
|
* Now positioned at the Files Area.
|
||||||
* If we have any arguments, process
|
* If we have any arguments, process
|
||||||
* them and write out.
|
* them and write out.
|
||||||
*/
|
*/
|
||||||
for(p = root; argc > 0; argc--, argv++, p += sizeof(Dosdir)){
|
for(p = root; argc > 0; argc--, argv++, p += sizeof(Dosdir)){
|
||||||
@ -745,7 +745,7 @@ if(chatty) print("files @%lluX\n", seek(disk->wfd, 0LL, 1));
|
|||||||
length *= secsize*clustersize;
|
length *= secsize*clustersize;
|
||||||
if((buf = malloc(length)) == 0)
|
if((buf = malloc(length)) == 0)
|
||||||
fatal("out of memory");
|
fatal("out of memory");
|
||||||
|
|
||||||
if(readn(sysfd, buf, d->length) != d->length)
|
if(readn(sysfd, buf, d->length) != d->length)
|
||||||
fatal("read %s: %r", *argv);
|
fatal("read %s: %r", *argv);
|
||||||
memset(buf+d->length, 0, length-d->length);
|
memset(buf+d->length, 0, length-d->length);
|
||||||
@ -755,7 +755,7 @@ if(chatty) print("%s @%lluX\n", d->name, seek(disk->wfd, 0LL, 1));
|
|||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
close(sysfd);
|
close(sysfd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate the FAT clusters.
|
* Allocate the FAT clusters.
|
||||||
* We're assuming here that where we
|
* We're assuming here that where we
|
||||||
@ -796,7 +796,7 @@ fprint(2, "add %s at clust %lux\n", d->name, x);
|
|||||||
PUTLONG(fi->sig, FATINFOSIG);
|
PUTLONG(fi->sig, FATINFOSIG);
|
||||||
PUTLONG(fi->freeclust, clusters - fatlast);
|
PUTLONG(fi->freeclust, clusters - fatlast);
|
||||||
PUTLONG(fi->nextfree, fatlast);
|
PUTLONG(fi->nextfree, fatlast);
|
||||||
|
|
||||||
if(seek(disk->wfd, (nresrv-1)*secsize, 0) < 0)
|
if(seek(disk->wfd, (nresrv-1)*secsize, 0) < 0)
|
||||||
fatal("seek to fatinfo: %r\n");
|
fatal("seek to fatinfo: %r\n");
|
||||||
if(write(disk->wfd, fi, secsize) < 0)
|
if(write(disk->wfd, fi, secsize) < 0)
|
||||||
@ -853,7 +853,7 @@ clustalloc(int flag)
|
|||||||
fat[o+3] = x>>24;
|
fat[o+3] = x>>24;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flag == Eof)
|
if(flag == Eof)
|
||||||
return 0;
|
return 0;
|
||||||
else{
|
else{
|
||||||
|
@ -62,7 +62,7 @@ main(int argc, char **argv)
|
|||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
Binits(&bin, 0, OREAD, binbuf, sizeof binbuf);
|
Binits(&bin, 0, OREAD, binbuf, sizeof binbuf);
|
||||||
while(p = Brdline(&bin, '\n')){
|
while(p = Brdline(&bin, '\n')){
|
||||||
p[Blinelen(&bin)-1] = '\0';
|
p[Blinelen(&bin)-1] = '\0';
|
||||||
@ -142,7 +142,7 @@ mkdirs(char *name, char *namep)
|
|||||||
if(p[1] == '\0')
|
if(p[1] == '\0')
|
||||||
return;
|
return;
|
||||||
*p = 0;
|
*p = 0;
|
||||||
fd = create(buf, OREAD, 0775|DMDIR);
|
fd = ocreate(buf, OREAD, 0775|DMDIR);
|
||||||
close(fd);
|
close(fd);
|
||||||
*p = '/';
|
*p = '/';
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ mkdir(char *name, uint32_t mode, uint32_t mtime, char *uid, char *gid)
|
|||||||
char *p;
|
char *p;
|
||||||
char olderr[256];
|
char olderr[256];
|
||||||
|
|
||||||
fd = create(name, OREAD, mode);
|
fd = ocreate(name, OREAD, mode);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
rerrstr(olderr, sizeof(olderr));
|
rerrstr(olderr, sizeof(olderr));
|
||||||
if((d = dirstat(name)) == nil || !(d->mode & DMDIR)){
|
if((d = dirstat(name)) == nil || !(d->mode & DMDIR)){
|
||||||
|
@ -179,7 +179,7 @@ copy(Dir *d)
|
|||||||
if(!p)
|
if(!p)
|
||||||
error("internal temporary file error");
|
error("internal temporary file error");
|
||||||
strcpy(p+1, "__mkfstmp");
|
strcpy(p+1, "__mkfstmp");
|
||||||
t = create(cptmp, OWRITE, 0666);
|
t = ocreate(cptmp, OWRITE, 0666);
|
||||||
if(t < 0){
|
if(t < 0){
|
||||||
warn("can't create %q: %r", newfile);
|
warn("can't create %q: %r", newfile);
|
||||||
close(f);
|
close(f);
|
||||||
@ -261,7 +261,7 @@ mkdir(Dir *d)
|
|||||||
arch(d);
|
arch(d);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fd = create(newfile, OREAD, d->mode);
|
fd = ocreate(newfile, OREAD, d->mode);
|
||||||
nulldir(&nd);
|
nulldir(&nd);
|
||||||
nd.mode = d->mode;
|
nd.mode = d->mode;
|
||||||
nd.gid = d->gid;
|
nd.gid = d->gid;
|
||||||
|
@ -233,7 +233,7 @@ main(int argc, char *argv[])
|
|||||||
sysfatal("pipe: %r");
|
sysfatal("pipe: %r");
|
||||||
if(srv){
|
if(srv){
|
||||||
snprint(buf, sizeof buf, "#s/%s", srvname);
|
snprint(buf, sizeof buf, "#s/%s", srvname);
|
||||||
fd = create(buf, OWRITE, 0666);
|
fd = ocreate(buf, OWRITE, 0666);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
sysfatal("create %s: %r", buf);
|
sysfatal("create %s: %r", buf);
|
||||||
if(fprint(fd, "%d", pfd[0]) < 0)
|
if(fprint(fd, "%d", pfd[0]) < 0)
|
||||||
|
@ -106,7 +106,7 @@ main(int argc, char **argv)
|
|||||||
open("/dev/null", OWRITE);
|
open("/dev/null", OWRITE);
|
||||||
if(pipe(pipefd) < 0)
|
if(pipe(pipefd) < 0)
|
||||||
panic("pipe");
|
panic("pipe");
|
||||||
srvfd = create(srvfile, OWRITE|ORCLOSE, 0600);
|
srvfd = ocreate(srvfile, OWRITE|ORCLOSE, 0600);
|
||||||
if(srvfd < 0)
|
if(srvfd < 0)
|
||||||
panic(srvfile);
|
panic(srvfile);
|
||||||
fprint(srvfd, "%d", pipefd[0]);
|
fprint(srvfd, "%d", pipefd[0]);
|
||||||
|
@ -382,7 +382,7 @@ commands(void)
|
|||||||
if(!wrapp ||
|
if(!wrapp ||
|
||||||
((io = open(file, OWRITE)) == -1) ||
|
((io = open(file, OWRITE)) == -1) ||
|
||||||
((seek(io, 0L, 2)) == -1))
|
((seek(io, 0L, 2)) == -1))
|
||||||
if((io = create(file, OWRITE, 0666)) < 0)
|
if((io = ocreate(file, OWRITE, 0666)) < 0)
|
||||||
error(file);
|
error(file);
|
||||||
Binit(&iobuf, io, OWRITE);
|
Binit(&iobuf, io, OWRITE);
|
||||||
wrapp = 0;
|
wrapp = 0;
|
||||||
@ -681,7 +681,7 @@ rescue(void)
|
|||||||
if(dol > zero) {
|
if(dol > zero) {
|
||||||
addr1 = zero+1;
|
addr1 = zero+1;
|
||||||
addr2 = dol;
|
addr2 = dol;
|
||||||
io = create("ed.hup", OWRITE, 0666);
|
io = ocreate("ed.hup", OWRITE, 0666);
|
||||||
if(io > 0){
|
if(io > 0){
|
||||||
Binit(&iobuf, io, OWRITE);
|
Binit(&iobuf, io, OWRITE);
|
||||||
putfile();
|
putfile();
|
||||||
@ -1110,7 +1110,7 @@ init(void)
|
|||||||
iblock = -1;
|
iblock = -1;
|
||||||
oblock = -1;
|
oblock = -1;
|
||||||
ichanged = 0;
|
ichanged = 0;
|
||||||
if((tfile = create(tfname, ORDWR, 0600)) < 0){
|
if((tfile = ocreate(tfname, ORDWR, 0600)) < 0){
|
||||||
error1(T);
|
error1(T);
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ main(int argc, char **argv)
|
|||||||
remote = na;
|
remote = na;
|
||||||
if((fd = dial(netmkaddr(na, 0, "importfs"), 0, 0, 0)) < 0)
|
if((fd = dial(netmkaddr(na, 0, "importfs"), 0, 0, 0)) < 0)
|
||||||
sysfatal("can't dial %s: %r", na);
|
sysfatal("can't dial %s: %r", na);
|
||||||
|
|
||||||
ai = auth_proxy(fd, auth_getkey, "proto=p9any role=client %s", keyspec);
|
ai = auth_proxy(fd, auth_getkey, "proto=p9any role=client %s", keyspec);
|
||||||
if(ai == nil)
|
if(ai == nil)
|
||||||
sysfatal("%r: %s", na);
|
sysfatal("%r: %s", na);
|
||||||
@ -242,7 +242,7 @@ main(int argc, char **argv)
|
|||||||
exclusions();
|
exclusions();
|
||||||
|
|
||||||
if(dbg) {
|
if(dbg) {
|
||||||
n = create(dbfile, OWRITE|OTRUNC, 0666);
|
n = ocreate(dbfile, OWRITE|OTRUNC, 0666);
|
||||||
dup(n, DFD);
|
dup(n, DFD);
|
||||||
close(n);
|
close(n);
|
||||||
}
|
}
|
||||||
@ -328,12 +328,12 @@ main(int argc, char **argv)
|
|||||||
if (n == 0)
|
if (n == 0)
|
||||||
fatal("connection closed while reading arguments\n");
|
fatal("connection closed while reading arguments\n");
|
||||||
|
|
||||||
if (*p == '\n')
|
if (*p == '\n')
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if (*p++ == '\0')
|
if (*p++ == '\0')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenize(buf, args, nelem(args)) != 2)
|
if (tokenize(buf, args, nelem(args)) != 2)
|
||||||
fatal("impo arguments invalid: impo%s...\n", buf);
|
fatal("impo arguments invalid: impo%s...\n", buf);
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ main(int argc, char **argv)
|
|||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < 4; i++)
|
||||||
key[i+12] = rand();
|
key[i+12] = rand();
|
||||||
|
|
||||||
if (initial)
|
if (initial)
|
||||||
fatal("Protocol botch: old import\n");
|
fatal("Protocol botch: old import\n");
|
||||||
if(readn(netfd, key, 4) != 4)
|
if(readn(netfd, key, 4) != 4)
|
||||||
fatal("can't read key part; %r\n");
|
fatal("can't read key part; %r\n");
|
||||||
@ -385,7 +385,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
switch (encproto) {
|
switch (encproto) {
|
||||||
case Encssl:
|
case Encssl:
|
||||||
netfd = pushssl(netfd, ealgs, fromserversecret,
|
netfd = pushssl(netfd, ealgs, fromserversecret,
|
||||||
fromclientsecret, nil);
|
fromclientsecret, nil);
|
||||||
break;
|
break;
|
||||||
case Enctls:
|
case Enctls:
|
||||||
@ -397,7 +397,7 @@ main(int argc, char **argv)
|
|||||||
fatal("can't establish ssl connection: %r");
|
fatal("can't establish ssl connection: %r");
|
||||||
}
|
}
|
||||||
else if (filterp) {
|
else if (filterp) {
|
||||||
if (initial)
|
if (initial)
|
||||||
fatal("Protocol botch: don't know how to deal with this\n");
|
fatal("Protocol botch: don't know how to deal with this\n");
|
||||||
netfd = filter(netfd, filterp);
|
netfd = filter(netfd, filterp);
|
||||||
}
|
}
|
||||||
@ -409,7 +409,7 @@ main(int argc, char **argv)
|
|||||||
r = getsbuf();
|
r = getsbuf();
|
||||||
if(r == 0)
|
if(r == 0)
|
||||||
fatal("Out of service buffers");
|
fatal("Out of service buffers");
|
||||||
|
|
||||||
n = localread9pmsg(netfd, r->buf, messagesize, &initial);
|
n = localread9pmsg(netfd, r->buf, messagesize, &initial);
|
||||||
if(n <= 0)
|
if(n <= 0)
|
||||||
fatal(nil);
|
fatal(nil);
|
||||||
@ -423,7 +423,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WARNING: Replace this with the original version as soon as all
|
* WARNING: Replace this with the original version as soon as all
|
||||||
* _old_ imports have been replaced with negotiating imports. Also
|
* _old_ imports have been replaced with negotiating imports. Also
|
||||||
* cpu relies on this (which needs to be fixed!) -- pb.
|
* cpu relies on this (which needs to be fixed!) -- pb.
|
||||||
*/
|
*/
|
||||||
@ -473,7 +473,7 @@ reply(Fcall *r, Fcall *t, char *err)
|
|||||||
t->type = Rerror;
|
t->type = Rerror;
|
||||||
t->ename = err;
|
t->ename = err;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
t->type = r->type + 1;
|
t->type = r->type + 1;
|
||||||
|
|
||||||
DEBUG(DFD, "\t%F\n", t);
|
DEBUG(DFD, "\t%F\n", t);
|
||||||
@ -531,7 +531,7 @@ freefid(int nr)
|
|||||||
l = &f->next;
|
l = &f->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fid *
|
Fid *
|
||||||
@ -564,7 +564,7 @@ newfid(int nr)
|
|||||||
new->fid = -1;
|
new->fid = -1;
|
||||||
new->mid = 0;
|
new->mid = 0;
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fsrpc *
|
Fsrpc *
|
||||||
@ -869,7 +869,7 @@ fatal(char *s, ...)
|
|||||||
postnote(PNPROC, m->pid, "kill");
|
postnote(PNPROC, m->pid, "kill");
|
||||||
|
|
||||||
DEBUG(DFD, "%s\n", buf);
|
DEBUG(DFD, "%s\n", buf);
|
||||||
if (s)
|
if (s)
|
||||||
sysfatal("%s", buf); /* caution: buf could contain '%' */
|
sysfatal("%s", buf); /* caution: buf could contain '%' */
|
||||||
else
|
else
|
||||||
exits(nil);
|
exits(nil);
|
||||||
@ -920,7 +920,7 @@ filter(int fd, char *cmd)
|
|||||||
if ((s = strchr(newport, '\n')) != nil)
|
if ((s = strchr(newport, '\n')) != nil)
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
|
|
||||||
if ((nb = write(fd, newport, len)) < 0)
|
if ((nb = write(fd, newport, len)) < 0)
|
||||||
sysfatal("getport; cannot write port; %r");
|
sysfatal("getport; cannot write port; %r");
|
||||||
assert(nb == len);
|
assert(nb == len);
|
||||||
|
|
||||||
@ -952,7 +952,7 @@ filter(int fd, char *cmd)
|
|||||||
close(fd);
|
close(fd);
|
||||||
close(p[0]);
|
close(p[0]);
|
||||||
}
|
}
|
||||||
return p[1];
|
return p[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -311,7 +311,7 @@ Xcreate(Fsrpc *t)
|
|||||||
|
|
||||||
|
|
||||||
path = makepath(f->f, t->work.name);
|
path = makepath(f->f, t->work.name);
|
||||||
f->fid = create(path, t->work.mode, t->work.perm);
|
f->fid = ocreate(path, t->work.mode, t->work.perm);
|
||||||
free(path);
|
free(path);
|
||||||
if(f->fid < 0) {
|
if(f->fid < 0) {
|
||||||
errstr(err, sizeof err);
|
errstr(err, sizeof err);
|
||||||
|
@ -131,7 +131,7 @@ copy(char *from, char *to, int todir)
|
|||||||
failed = 1;
|
failed = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fdt=create(to, OWRITE, mode);
|
fdt=ocreate(to, OWRITE, mode);
|
||||||
if(fdt<0){
|
if(fdt<0){
|
||||||
fprint(2, "fcp: can't create %s: %r\n", to);
|
fprint(2, "fcp: can't create %s: %r\n", to);
|
||||||
close(fdf);
|
close(fdf);
|
||||||
@ -151,7 +151,7 @@ copy(char *from, char *to, int todir)
|
|||||||
dirt.gid = dirb->gid;
|
dirt.gid = dirb->gid;
|
||||||
if(dirfwstat(fdt, &dirt) < 0)
|
if(dirfwstat(fdt, &dirt) < 0)
|
||||||
fprint(2, "fcp: warning: can't wstat %s: %r\n", to);
|
fprint(2, "fcp: warning: can't wstat %s: %r\n", to);
|
||||||
}
|
}
|
||||||
free(dirb);
|
free(dirb);
|
||||||
close(fdf);
|
close(fdf);
|
||||||
close(fdt);
|
close(fdt);
|
||||||
|
@ -152,7 +152,7 @@ main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
p = seprint(p, e, "%s", t);
|
p = seprint(p, e, "%s", t);
|
||||||
u.postbody = postbody;
|
u.postbody = postbody;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
@ -168,7 +168,7 @@ main(int argc, char **argv)
|
|||||||
if(argc != 1)
|
if(argc != 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
|
||||||
out.fd = 1;
|
out.fd = 1;
|
||||||
out.written = 0;
|
out.written = 0;
|
||||||
out.offset = 0;
|
out.offset = 0;
|
||||||
@ -177,7 +177,7 @@ main(int argc, char **argv)
|
|||||||
if(ofile != nil){
|
if(ofile != nil){
|
||||||
d = dirstat(ofile);
|
d = dirstat(ofile);
|
||||||
if(d == nil){
|
if(d == nil){
|
||||||
out.fd = create(ofile, OWRITE, 0664);
|
out.fd = ocreate(ofile, OWRITE, 0664);
|
||||||
if(out.fd < 0)
|
if(out.fd < 0)
|
||||||
sysfatal("creating %s: %r", ofile);
|
sysfatal("creating %s: %r", ofile);
|
||||||
} else {
|
} else {
|
||||||
@ -238,7 +238,7 @@ crackurl(URL *u, char *s)
|
|||||||
u->page = nil;
|
u->page = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get type */
|
/* get type */
|
||||||
for(p = s; *p; p++){
|
for(p = s; *p; p++){
|
||||||
if(*p == '/'){
|
if(*p == '/'){
|
||||||
p = s;
|
p = s;
|
||||||
@ -288,7 +288,7 @@ crackurl(URL *u, char *s)
|
|||||||
if(p = strchr(u->host, ':')) {
|
if(p = strchr(u->host, ':')) {
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
u->port = p;
|
u->port = p;
|
||||||
} else
|
} else
|
||||||
u->port = method[u->method].name;
|
u->port = method[u->method].name;
|
||||||
|
|
||||||
if(*(u->host) == 0){
|
if(*(u->host) == 0){
|
||||||
@ -425,7 +425,7 @@ dohttp(URL *u, URL *px, Range *r, Out *out, int32_t mtime)
|
|||||||
cfd = -1;
|
cfd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dfprint(fd, "\r\n", u->host);
|
dfprint(fd, "\r\n", u->host);
|
||||||
if(u->postbody)
|
if(u->postbody)
|
||||||
dfprint(fd, "%s", u->postbody);
|
dfprint(fd, "%s", u->postbody);
|
||||||
@ -498,7 +498,7 @@ dohttp(URL *u, URL *px, Range *r, Out *out, int32_t mtime)
|
|||||||
|
|
||||||
case 503: /* Service unavailable */
|
case 503: /* Service unavailable */
|
||||||
sysfatal("Service unavailable");
|
sysfatal("Service unavailable");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sysfatal("Unknown response code %d", code);
|
sysfatal("Unknown response code %d", code);
|
||||||
}
|
}
|
||||||
@ -891,7 +891,7 @@ doftp(URL *u, URL *px, Range *r, Out *out, int32_t mtime)
|
|||||||
close(ctl);
|
close(ctl);
|
||||||
return Eof;
|
return Eof;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first try passive mode, then active */
|
/* first try passive mode, then active */
|
||||||
data = passive(ctl, u);
|
data = passive(ctl, u);
|
||||||
if(data < 0){
|
if(data < 0){
|
||||||
@ -1207,7 +1207,7 @@ active(int ctl, URL *u)
|
|||||||
}
|
}
|
||||||
close(afd);
|
close(afd);
|
||||||
close(lcfd);
|
close(lcfd);
|
||||||
|
|
||||||
return dfd;
|
return dfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ consproc(void *v)
|
|||||||
char *s;
|
char *s;
|
||||||
char *args[MAXARGS];
|
char *args[MAXARGS];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
in = (Biobuf *) v;
|
in = (Biobuf *) v;
|
||||||
for(;;){
|
for(;;){
|
||||||
s = Brdstr(in, '\n', 1);
|
s = Brdstr(in, '\n', 1);
|
||||||
@ -398,7 +398,7 @@ initcons(char *service)
|
|||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
snprint(buf, sizeof(buf), "/srv/%s.cmd", service);
|
snprint(buf, sizeof(buf), "/srv/%s.cmd", service);
|
||||||
fd = create(buf, OWRITE|ORCLOSE, 0600);
|
fd = ocreate(buf, OWRITE|ORCLOSE, 0600);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
pipe(pfd);
|
pipe(pfd);
|
||||||
|
@ -58,7 +58,7 @@ enabledebug(const char *file)
|
|||||||
if (!debugging) {
|
if (!debugging) {
|
||||||
if((fd = open(file, OCEXEC|OTRUNC|OWRITE)) < 0){
|
if((fd = open(file, OCEXEC|OTRUNC|OWRITE)) < 0){
|
||||||
debug("open: %r\n");
|
debug("open: %r\n");
|
||||||
if((fd = create(file, OCEXEC|OWRITE, 0666)) < 0)
|
if((fd = ocreate(file, OCEXEC|OWRITE, 0666)) < 0)
|
||||||
sysfatal("create %r");
|
sysfatal("create %r");
|
||||||
}
|
}
|
||||||
dup(fd, 2);
|
dup(fd, 2);
|
||||||
@ -211,9 +211,9 @@ post(char *srv, int fd)
|
|||||||
|
|
||||||
fprint(2, "post %s...\n", srv);
|
fprint(2, "post %s...\n", srv);
|
||||||
sprint(buf, "#s/%s", srv);
|
sprint(buf, "#s/%s", srv);
|
||||||
f = create(buf, OWRITE, 0666);
|
f = ocreate(buf, OWRITE, 0666);
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
sysfatal("create(%s)", srv);
|
sysfatal("ocreate(%s)", srv);
|
||||||
sprint(buf, "%d", fd);
|
sprint(buf, "%d", fd);
|
||||||
if(write(f, buf, strlen(buf)) != strlen(buf))
|
if(write(f, buf, strlen(buf)) != strlen(buf))
|
||||||
sysfatal("write");
|
sysfatal("write");
|
||||||
|
@ -23,7 +23,7 @@ void warning(char*, char*);
|
|||||||
%token <sym> FUNCTION PROCEDURE RETURN FUNC PROC READ
|
%token <sym> FUNCTION PROCEDURE RETURN FUNC PROC READ
|
||||||
%type <formals> formals
|
%type <formals> formals
|
||||||
%type <inst> expr stmt asgn prlist stmtlist
|
%type <inst> expr stmt asgn prlist stmtlist
|
||||||
%type <inst> cond while for if begin end
|
%type <inst> cond while for if begin end
|
||||||
%type <sym> procname
|
%type <sym> procname
|
||||||
%type <narg> arglist
|
%type <narg> arglist
|
||||||
%right '=' ADDEQ SUBEQ MULEQ DIVEQ MODEQ
|
%right '=' ADDEQ SUBEQ MULEQ DIVEQ MODEQ
|
||||||
@ -39,7 +39,7 @@ list: /* nothing */
|
|||||||
| list '\n'
|
| list '\n'
|
||||||
| list defn '\n'
|
| list defn '\n'
|
||||||
| list asgn '\n' { code2(xpop, STOP); return 1; }
|
| list asgn '\n' { code2(xpop, STOP); return 1; }
|
||||||
| list stmt '\n' { code(STOP); return 1; }
|
| list stmt '\n' { code(STOP); return 1; }
|
||||||
| list expr '\n' { code2(printtop, STOP); return 1; }
|
| list expr '\n' { code2(printtop, STOP); return 1; }
|
||||||
| list error '\n' { yyerrok; }
|
| list error '\n' { yyerrok; }
|
||||||
;
|
;
|
||||||
@ -357,7 +357,7 @@ moreinput(void)
|
|||||||
expr = infile+2;
|
expr = infile+2;
|
||||||
sprint(buf, "/tmp/hocXXXXXXX");
|
sprint(buf, "/tmp/hocXXXXXXX");
|
||||||
infile = mktemp(buf);
|
infile = mktemp(buf);
|
||||||
fd = create(infile, ORDWR|ORCLOSE, 0600);
|
fd = ocreate(infile, ORDWR|ORCLOSE, 0600);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
fprint(2, "%s: can't create temp. file: %r\n", progname);
|
fprint(2, "%s: can't create temp. file: %r\n", progname);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -75,7 +75,7 @@ post(char *name, char *envname, int srvfd)
|
|||||||
int fd;
|
int fd;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
fd = create(name, OWRITE, 0600);
|
fd = ocreate(name, OWRITE, 0600);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
sprint(buf, "%d",srvfd);
|
sprint(buf, "%d",srvfd);
|
||||||
|
@ -220,7 +220,7 @@ setenv(char *name, char *val)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = create(name, OWRITE, 0644);
|
fd = ocreate(name, OWRITE, 0644);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
fprint(2, "init: can't create %s: %r\n", name);
|
fprint(2, "init: can't create %s: %r\n", name);
|
||||||
else{
|
else{
|
||||||
|
@ -106,7 +106,7 @@ lockopen(char *file)
|
|||||||
}
|
}
|
||||||
if(strstr(err, "exist")){
|
if(strstr(err, "exist")){
|
||||||
/* no file, create an exclusive access file */
|
/* no file, create an exclusive access file */
|
||||||
fd = create(file, ORDWR, DMEXCL|0664);
|
fd = ocreate(file, ORDWR, DMEXCL|0664);
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ commitbinding(Binding *b)
|
|||||||
}
|
}
|
||||||
setbinding(b, b->offeredto, now + b->offer);
|
setbinding(b, b->offeredto, now + b->offer);
|
||||||
b->lasttouched = now;
|
b->lasttouched = now;
|
||||||
|
|
||||||
if(writebinding(fd, b) < 0){
|
if(writebinding(fd, b) < 0){
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
@ -429,7 +429,7 @@ releasebinding(Binding *b, char *id)
|
|||||||
}
|
}
|
||||||
b->lease = 0;
|
b->lease = 0;
|
||||||
b->expoffer = 0;
|
b->expoffer = 0;
|
||||||
|
|
||||||
if(writebinding(fd, b) < 0){
|
if(writebinding(fd, b) < 0){
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1306,7 +1306,7 @@ openfreqfile(void)
|
|||||||
}
|
}
|
||||||
fd = open(p, ORDWR);
|
fd = open(p, ORDWR);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
fd = create(p, ORDWR, 0666);
|
fd = ocreate(p, ORDWR, 0666);
|
||||||
free(p);
|
free(p);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -129,7 +129,7 @@ main(int argc, char *argv[])
|
|||||||
case -1:
|
case -1:
|
||||||
error("fork");
|
error("fork");
|
||||||
case 0:
|
case 0:
|
||||||
fd = create("/env/prompt", OWRITE, 0666);
|
fd = ocreate("/env/prompt", OWRITE, 0666);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
fprint(fd, "%s%% ", lock);
|
fprint(fd, "%s%% ", lock);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -38,7 +38,7 @@ main(int argc, char *argv[])
|
|||||||
dirfrom = nil;
|
dirfrom = nil;
|
||||||
if(argc == 3
|
if(argc == 3
|
||||||
&& (dirfrom = dirstat(argv[1])) != nil
|
&& (dirfrom = dirstat(argv[1])) != nil
|
||||||
&& (dirfrom->mode & DMDIR))
|
&& (dirfrom->mode & DMDIR))
|
||||||
split(argv[argc-1], &todir, &toelem); /* mv dir1 dir2 */
|
split(argv[argc-1], &todir, &toelem); /* mv dir1 dir2 */
|
||||||
else{ /* mv file... dir */
|
else{ /* mv file... dir */
|
||||||
todir = argv[argc-1];
|
todir = argv[argc-1];
|
||||||
@ -150,7 +150,7 @@ mv1(char *from, Dir *dirb, char *todir, char *toelem)
|
|||||||
hardremove(toname); /* because create() won't truncate file */
|
hardremove(toname); /* because create() won't truncate file */
|
||||||
free(dirt);
|
free(dirt);
|
||||||
|
|
||||||
fdt = create(toname, OWRITE, dirb->mode);
|
fdt = ocreate(toname, OWRITE, dirb->mode);
|
||||||
if(fdt < 0){
|
if(fdt < 0){
|
||||||
fprint(2, "mv: can't create %s: %r\n", toname);
|
fprint(2, "mv: can't create %s: %r\n", toname);
|
||||||
close(fdf);
|
close(fdf);
|
||||||
|
@ -308,7 +308,7 @@ mountinit(char *service, char *mntpt)
|
|||||||
/*
|
/*
|
||||||
* make a /srv/cs
|
* make a /srv/cs
|
||||||
*/
|
*/
|
||||||
f = create(service, OWRITE|ORCLOSE, 0666);
|
f = ocreate(service, OWRITE|ORCLOSE, 0666);
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
error(service);
|
error(service);
|
||||||
snprint(buf, sizeof(buf), "%d", p[1]);
|
snprint(buf, sizeof(buf), "%d", p[1]);
|
||||||
|
@ -257,7 +257,7 @@ dnstats(char *file)
|
|||||||
{
|
{
|
||||||
int i, fd;
|
int i, fd;
|
||||||
|
|
||||||
fd = create(file, OWRITE, 0666);
|
fd = ocreate(file, OWRITE, 0666);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ dndump(char *file)
|
|||||||
DN *dp;
|
DN *dp;
|
||||||
RR *rp;
|
RR *rp;
|
||||||
|
|
||||||
fd = create(file, OWRITE, 0666);
|
fd = ocreate(file, OWRITE, 0666);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ rrattach1(RR *new, int auth)
|
|||||||
if(rp->negative != new->negative) {
|
if(rp->negative != new->negative) {
|
||||||
/* rp == *l before; *l == rp->next after */
|
/* rp == *l before; *l == rp->next after */
|
||||||
rrdelhead(l);
|
rrdelhead(l);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* all things equal, pick the newer one */
|
/* all things equal, pick the newer one */
|
||||||
else if(rp->arg0 == new->arg0 && rp->arg1 == new->arg1){
|
else if(rp->arg0 == new->arg0 && rp->arg1 == new->arg1){
|
||||||
|
@ -267,7 +267,7 @@ mountinit(char *service, char *mntpt)
|
|||||||
/*
|
/*
|
||||||
* make a /srv/dns
|
* make a /srv/dns
|
||||||
*/
|
*/
|
||||||
if((f = create(service, OWRITE|ORCLOSE, 0666)) < 0)
|
if((f = ocreate(service, OWRITE|ORCLOSE, 0666)) < 0)
|
||||||
sysfatal("create %s failed: %r", service);
|
sysfatal("create %s failed: %r", service);
|
||||||
snprint(buf, sizeof buf, "%d", p[1]);
|
snprint(buf, sizeof buf, "%d", p[1]);
|
||||||
if(write(f, buf, strlen(buf)) != strlen(buf))
|
if(write(f, buf, strlen(buf)) != strlen(buf))
|
||||||
|
@ -68,7 +68,7 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
Ndbtuple *t, *nt;
|
Ndbtuple *t, *nt;
|
||||||
int n;
|
int n;
|
||||||
Dir *d;
|
Dir *d;
|
||||||
uint8_t buf[8];
|
uint8_t buf[8];
|
||||||
char file[128];
|
char file[128];
|
||||||
int fd;
|
int fd;
|
||||||
@ -125,7 +125,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* create the hash file */
|
/* create the hash file */
|
||||||
snprint(file, sizeof(file), "%s.%s", argv[1], argv[2]);
|
snprint(file, sizeof(file), "%s.%s", argv[1], argv[2]);
|
||||||
fd = create(file, ORDWR, 0664);
|
fd = ocreate(file, ORDWR, 0664);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
fprint(2, "mkhash: can't create %s\n", file);
|
fprint(2, "mkhash: can't create %s\n", file);
|
||||||
exits(syserr());
|
exits(syserr());
|
||||||
|
@ -188,9 +188,9 @@ main(int argc, char *argv[])
|
|||||||
parse("/cfg/ndb/local");
|
parse("/cfg/ndb/local");
|
||||||
parse("/cfg/ndb/friends");
|
parse("/cfg/ndb/friends");
|
||||||
}
|
}
|
||||||
|
|
||||||
sprint(fn, "/cfg/ndb/db.%-.24s", domname);
|
sprint(fn, "/cfg/ndb/db.%-.24s", domname);
|
||||||
fd = create(fn, OWRITE, 0664);
|
fd = ocreate(fn, OWRITE, 0664);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
fprint(2, "can't create %s: %r\n", fn);
|
fprint(2, "can't create %s: %r\n", fn);
|
||||||
exits("boom");
|
exits("boom");
|
||||||
@ -201,7 +201,7 @@ main(int argc, char *argv[])
|
|||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
sprint(fn, "/cfg/ndb/equiv.%-.21s", domname);
|
sprint(fn, "/cfg/ndb/equiv.%-.21s", domname);
|
||||||
fd = create(fn, OWRITE, 0664);
|
fd = ocreate(fn, OWRITE, 0664);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
fprint(2, "can't create %s: %r\n", fn);
|
fprint(2, "can't create %s: %r\n", fn);
|
||||||
exits("boom");
|
exits("boom");
|
||||||
@ -211,7 +211,7 @@ main(int argc, char *argv[])
|
|||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
sprint(fn, "/cfg/ndb/txt.%-.23s", domname);
|
sprint(fn, "/cfg/ndb/txt.%-.23s", domname);
|
||||||
fd = create(fn, OWRITE, 0664);
|
fd = ocreate(fn, OWRITE, 0664);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
fprint(2, "can't create %s: %r\n", fn);
|
fprint(2, "can't create %s: %r\n", fn);
|
||||||
exits("boom");
|
exits("boom");
|
||||||
|
@ -207,7 +207,7 @@ main(int argc, char *argv[])
|
|||||||
if(defmnt == 0){
|
if(defmnt == 0){
|
||||||
char buf[64];
|
char buf[64];
|
||||||
snprint(buf, sizeof buf, "#s/%s", service);
|
snprint(buf, sizeof buf, "#s/%s", service);
|
||||||
fd = create(buf, OWRITE|ORCLOSE, 0666);
|
fd = ocreate(buf, OWRITE|ORCLOSE, 0666);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
error("create failed");
|
error("create failed");
|
||||||
sprint(buf, "%d", p[1]);
|
sprint(buf, "%d", p[1]);
|
||||||
|
@ -562,7 +562,7 @@ Executable(char *file)
|
|||||||
int
|
int
|
||||||
Creat(char *file)
|
Creat(char *file)
|
||||||
{
|
{
|
||||||
return create(file, OWRITE, 0666L);
|
return ocreate(file, OWRITE, 0666L);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -89,7 +89,7 @@ post(char *name, char *envname, int srvfd)
|
|||||||
int fd;
|
int fd;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
fd = create(name, OWRITE|ORCLOSE|OCEXEC, 0600);
|
fd = ocreate(name, OWRITE|ORCLOSE|OCEXEC, 0600);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
error(name);
|
error(name);
|
||||||
snprint(buf, sizeof(buf), "%d", srvfd);
|
snprint(buf, sizeof(buf), "%d", srvfd);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the UCB release of Plan 9. It is subject to the license
|
* This file is part of the UCB release of Plan 9. It is subject to the license
|
||||||
* terms in the LICENSE file found in the top-level directory of this
|
* terms in the LICENSE file found in the top-level directory of this
|
||||||
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
||||||
@ -22,7 +22,7 @@ tempdisk(void)
|
|||||||
buf[5] = i;
|
buf[5] = i;
|
||||||
if(access(buf, AEXIST) == 0)
|
if(access(buf, AEXIST) == 0)
|
||||||
continue;
|
continue;
|
||||||
fd = create(buf, ORDWR|ORCLOSE|OCEXEC, 0600);
|
fd = ocreate(buf, ORDWR|ORCLOSE|OCEXEC, 0600);
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the UCB release of Plan 9. It is subject to the license
|
* This file is part of the UCB release of Plan 9. It is subject to the license
|
||||||
* terms in the LICENSE file found in the top-level directory of this
|
* terms in the LICENSE file found in the top-level directory of this
|
||||||
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
||||||
@ -55,7 +55,7 @@ writef(File *f)
|
|||||||
if(genc)
|
if(genc)
|
||||||
free(genc);
|
free(genc);
|
||||||
genc = Strtoc(&genstr);
|
genc = Strtoc(&genstr);
|
||||||
if((io=create(genc, OWRITE, 0666L)) < 0)
|
if((io=ocreate(genc, OWRITE, 0666L)) < 0)
|
||||||
error_r(Ecreate, genc);
|
error_r(Ecreate, genc);
|
||||||
dprint("%s: ", genc);
|
dprint("%s: ", genc);
|
||||||
if(statfd(io, 0, 0, 0, &length, &appendonly) > 0 && appendonly && length>0)
|
if(statfd(io, 0, 0, 0, &length, &appendonly) > 0 && appendonly && length>0)
|
||||||
@ -232,7 +232,7 @@ connectto(char *machine, char **argv)
|
|||||||
int p1[2], p2[2];
|
int p1[2], p2[2];
|
||||||
char **av;
|
char **av;
|
||||||
int ac;
|
int ac;
|
||||||
|
|
||||||
// count args
|
// count args
|
||||||
for(av = argv; *av; av++)
|
for(av = argv; *av; av++)
|
||||||
;
|
;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the UCB release of Plan 9. It is subject to the license
|
* This file is part of the UCB release of Plan 9. It is subject to the license
|
||||||
* terms in the LICENSE file found in the top-level directory of this
|
* terms in the LICENSE file found in the top-level directory of this
|
||||||
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
||||||
@ -98,7 +98,7 @@ journal(int out, char *s)
|
|||||||
static int fd = 0;
|
static int fd = 0;
|
||||||
|
|
||||||
if(fd <= 0)
|
if(fd <= 0)
|
||||||
fd = create("/tmp/sam.out", OWRITE, 0666L);
|
fd = ocreate("/tmp/sam.out", OWRITE, 0666L);
|
||||||
fprint(fd, "%s%s\n", out? "out: " : "in: ", s);
|
fprint(fd, "%s%s\n", out? "out: " : "in: ", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,7 +622,7 @@ vlong
|
|||||||
invlong(void)
|
invlong(void)
|
||||||
{
|
{
|
||||||
vlong v;
|
vlong v;
|
||||||
|
|
||||||
v = (inp[7]<<24) | (inp[6]<<16) | (inp[5]<<8) | inp[4];
|
v = (inp[7]<<24) | (inp[6]<<16) | (inp[5]<<8) | inp[4];
|
||||||
v = (v<<16) | (inp[3]<<8) | inp[2];
|
v = (v<<16) | (inp[3]<<8) | inp[2];
|
||||||
v = (v<<16) | (inp[1]<<8) | inp[0];
|
v = (v<<16) | (inp[1]<<8) | inp[0];
|
||||||
@ -785,7 +785,7 @@ void
|
|||||||
outshort(int s)
|
outshort(int s)
|
||||||
{
|
{
|
||||||
*outp++ = s;
|
*outp++ = s;
|
||||||
*outp++ = s>>8;
|
*outp++ = s>>8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the UCB release of Plan 9. It is subject to the license
|
* This file is part of the UCB release of Plan 9. It is subject to the license
|
||||||
* terms in the LICENSE file found in the top-level directory of this
|
* terms in the LICENSE file found in the top-level directory of this
|
||||||
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
||||||
@ -47,7 +47,7 @@ void main(int argc, char *argv[])
|
|||||||
int i;
|
int i;
|
||||||
String *t;
|
String *t;
|
||||||
char *termargs[10], **ap;
|
char *termargs[10], **ap;
|
||||||
|
|
||||||
ap = termargs;
|
ap = termargs;
|
||||||
*ap++ = "samterm";
|
*ap++ = "samterm";
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
@ -75,7 +75,7 @@ void main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}ARGEND
|
}ARGEND
|
||||||
*ap = nil;
|
*ap = nil;
|
||||||
|
|
||||||
Strinit(&cmdstr);
|
Strinit(&cmdstr);
|
||||||
Strinit0(&lastpat);
|
Strinit0(&lastpat);
|
||||||
Strinit0(&lastregexp);
|
Strinit0(&lastregexp);
|
||||||
@ -137,7 +137,7 @@ rescue(void)
|
|||||||
continue;
|
continue;
|
||||||
if(io == -1){
|
if(io == -1){
|
||||||
sprint(buf, "%s/sam.save", home);
|
sprint(buf, "%s/sam.save", home);
|
||||||
io = create(buf, OWRITE, 0777);
|
io = ocreate(buf, OWRITE, 0777);
|
||||||
if(io<0)
|
if(io<0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the UCB release of Plan 9. It is subject to the license
|
* This file is part of the UCB release of Plan 9. It is subject to the license
|
||||||
* terms in the LICENSE file found in the top-level directory of this
|
* terms in the LICENSE file found in the top-level directory of this
|
||||||
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
||||||
@ -41,9 +41,9 @@ plan9(File *f, int type, String *s, int nest)
|
|||||||
snarf(f, addr.r.p1, addr.r.p2, &plan9buf, 1);
|
snarf(f, addr.r.p1, addr.r.p2, &plan9buf, 1);
|
||||||
if((pid=fork()) == 0){
|
if((pid=fork()) == 0){
|
||||||
if(downloaded){ /* also put nasty fd's into errfile */
|
if(downloaded){ /* also put nasty fd's into errfile */
|
||||||
fd = create(errfile, OWRITE, 0666L);
|
fd = ocreate(errfile, OWRITE, 0666L);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
fd = create("/dev/null", OWRITE, 0666L);
|
fd = ocreate("/dev/null", OWRITE, 0666L);
|
||||||
dup(fd, 2);
|
dup(fd, 2);
|
||||||
close(fd);
|
close(fd);
|
||||||
/* 2 now points at err file */
|
/* 2 now points at err file */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the UCB release of Plan 9. It is subject to the license
|
* This file is part of the UCB release of Plan 9. It is subject to the license
|
||||||
* terms in the LICENSE file found in the top-level directory of this
|
* terms in the LICENSE file found in the top-level directory of this
|
||||||
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
||||||
@ -107,7 +107,7 @@ snarfswap(char *fromsam, int nc, char **tosam)
|
|||||||
free(s1);
|
free(s1);
|
||||||
} else
|
} else
|
||||||
s1[n] = 0;
|
s1[n] = 0;
|
||||||
f = create("/dev/snarf", OWRITE, 0666);
|
f = ocreate("/dev/snarf", OWRITE, 0666);
|
||||||
if(f >= 0){
|
if(f >= 0){
|
||||||
write(f, fromsam, nc);
|
write(f, fromsam, nc);
|
||||||
close(f);
|
close(f);
|
||||||
@ -167,7 +167,7 @@ extstart(void)
|
|||||||
if(pipe(p) < 0)
|
if(pipe(p) < 0)
|
||||||
return;
|
return;
|
||||||
sprint(exname, "/srv/sam.%s", getuser());
|
sprint(exname, "/srv/sam.%s", getuser());
|
||||||
fd = create(exname, OWRITE, 0600);
|
fd = ocreate(exname, OWRITE, 0600);
|
||||||
if(fd < 0){ /* assume existing guy is more important */
|
if(fd < 0){ /* assume existing guy is more important */
|
||||||
Err:
|
Err:
|
||||||
close(p[0]);
|
close(p[0]);
|
||||||
|
@ -616,7 +616,7 @@ open_file(char *name)
|
|||||||
if ((bp = malloc(sizeof(Biobuf))) == 0)
|
if ((bp = malloc(sizeof(Biobuf))) == 0)
|
||||||
quit("Out of memory");
|
quit("Out of memory");
|
||||||
if ((fd = open(name, OWRITE)) < 0 &&
|
if ((fd = open(name, OWRITE)) < 0 &&
|
||||||
(fd = create(name, OWRITE, 0666)) < 0)
|
(fd = ocreate(name, OWRITE, 0666)) < 0)
|
||||||
quit("Cannot create %s", name);
|
quit("Cannot create %s", name);
|
||||||
Binit(bp, fd, OWRITE);
|
Binit(bp, fd, OWRITE);
|
||||||
Bseek(bp, 0, 2);
|
Bseek(bp, 0, 2);
|
||||||
|
@ -191,7 +191,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
f = 1;
|
f = 1;
|
||||||
if(args.ofile) {
|
if(args.ofile) {
|
||||||
f = create(args.ofile, OWRITE, 0666);
|
f = ocreate(args.ofile, OWRITE, 0666);
|
||||||
if(f < 0) {
|
if(f < 0) {
|
||||||
fprint(2, "sort: create %s: %r\n", args.ofile);
|
fprint(2, "sort: create %s: %r\n", args.ofile);
|
||||||
done("create");
|
done("create");
|
||||||
@ -334,7 +334,7 @@ tempout(void)
|
|||||||
sort4(args.linep, args.nline);
|
sort4(args.linep, args.nline);
|
||||||
tf = tempfile(args.ntemp);
|
tf = tempfile(args.ntemp);
|
||||||
args.ntemp++;
|
args.ntemp++;
|
||||||
f = create(tf, OWRITE, 0666);
|
f = ocreate(tf, OWRITE, 0666);
|
||||||
if(f < 0) {
|
if(f < 0) {
|
||||||
fprint(2, "sort: create %s: %r\n", tf);
|
fprint(2, "sort: create %s: %r\n", tf);
|
||||||
done("create");
|
done("create");
|
||||||
@ -410,7 +410,7 @@ mergeout(Biobuf *b)
|
|||||||
if(n > Nmerge) {
|
if(n > Nmerge) {
|
||||||
tf = tempfile(args.ntemp);
|
tf = tempfile(args.ntemp);
|
||||||
args.ntemp++;
|
args.ntemp++;
|
||||||
f = create(tf, OWRITE, 0666);
|
f = ocreate(tf, OWRITE, 0666);
|
||||||
if(f < 0) {
|
if(f < 0) {
|
||||||
fprint(2, "sort: create %s: %r\n", tf);
|
fprint(2, "sort: create %s: %r\n", tf);
|
||||||
done("create");
|
done("create");
|
||||||
|
@ -110,7 +110,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in case we didn't end with a newline, tack whatever's
|
* in case we didn't end with a newline, tack whatever's
|
||||||
* left onto the last file
|
* left onto the last file
|
||||||
*/
|
*/
|
||||||
while((n = Bread(b, buf, sizeof(buf))) > 0)
|
while((n = Bread(b, buf, sizeof(buf))) > 0)
|
||||||
@ -132,7 +132,7 @@ nextfile(void)
|
|||||||
canopen = 0;
|
canopen = 0;
|
||||||
} else {
|
} else {
|
||||||
snprint(name, sizeof name, "%s%s", stem, suff);
|
snprint(name, sizeof name, "%s%s", stem, suff);
|
||||||
if(++suff[1] > 'z')
|
if(++suff[1] > 'z')
|
||||||
suff[1] = 'a', ++suff[0];
|
suff[1] = 'a', ++suff[0];
|
||||||
openf();
|
openf();
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ matchfile(Resub *match)
|
|||||||
strcpy(name+len, suffix);
|
strcpy(name+len, suffix);
|
||||||
openf();
|
openf();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return nextfile();
|
return nextfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ openf(void)
|
|||||||
Bterm(output);
|
Bterm(output);
|
||||||
if(fd > 0)
|
if(fd > 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = create(name,OWRITE,0666);
|
fd = ocreate(name,OWRITE,0666);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
fprint(2, "grep: can't create %s: %r\n", name);
|
fprint(2, "grep: can't create %s: %r\n", name);
|
||||||
exits("create");
|
exits("create");
|
||||||
|
@ -228,7 +228,7 @@ post(char *srv, int fd)
|
|||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
fprint(2, "post...\n");
|
fprint(2, "post...\n");
|
||||||
f = create(srv, OWRITE, 0666);
|
f = ocreate(srv, OWRITE, 0666);
|
||||||
if(f < 0){
|
if(f < 0){
|
||||||
sprint(buf, "create(%s)", srv);
|
sprint(buf, "create(%s)", srv);
|
||||||
error(buf);
|
error(buf);
|
||||||
|
@ -91,7 +91,7 @@ main(int argc, char **argv)
|
|||||||
strecpy(buf, buf+sizeof buf, argv[0]);
|
strecpy(buf, buf+sizeof buf, argv[0]);
|
||||||
else
|
else
|
||||||
snprint(buf, sizeof buf, "/srv/%s", argv[0]);
|
snprint(buf, sizeof buf, "/srv/%s", argv[0]);
|
||||||
fd = create(buf, OWRITE, perm);
|
fd = ocreate(buf, OWRITE, perm);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
fprint(2, "can't create %s: %r\n", buf);
|
fprint(2, "can't create %s: %r\n", buf);
|
||||||
exits("create");
|
exits("create");
|
||||||
|
@ -882,7 +882,7 @@ replace(char **argv)
|
|||||||
Pushstate ps;
|
Pushstate ps;
|
||||||
|
|
||||||
if (usefile && docreate)
|
if (usefile && docreate)
|
||||||
ar = create(usefile, OWRITE, 0666);
|
ar = ocreate(usefile, OWRITE, 0666);
|
||||||
else if (usefile)
|
else if (usefile)
|
||||||
ar = open(usefile, ORDWR);
|
ar = open(usefile, ORDWR);
|
||||||
else
|
else
|
||||||
@ -1065,10 +1065,10 @@ openfname(Hdr *hp, char *fname, int dir, int mode)
|
|||||||
if (!keepexisting || access(fname, AEXIST) < 0) {
|
if (!keepexisting || access(fname, AEXIST) < 0) {
|
||||||
int rw = (dir? OREAD: OWRITE);
|
int rw = (dir? OREAD: OWRITE);
|
||||||
|
|
||||||
fd = create(fname, rw, mode);
|
fd = ocreate(fname, rw, mode);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
mkpdirs(fname);
|
mkpdirs(fname);
|
||||||
fd = create(fname, rw, mode);
|
fd = ocreate(fname, rw, mode);
|
||||||
}
|
}
|
||||||
if (fd < 0 && (!dir || xaccess(fname, AEXIST) < 0))
|
if (fd < 0 && (!dir || xaccess(fname, AEXIST) < 0))
|
||||||
cantcreate(fname, mode);
|
cantcreate(fname, mode);
|
||||||
|
@ -56,10 +56,10 @@ main(int argc, char **argv)
|
|||||||
if(aflag) {
|
if(aflag) {
|
||||||
openf[n] = open(argv[0], OWRITE);
|
openf[n] = open(argv[0], OWRITE);
|
||||||
if(openf[n] < 0)
|
if(openf[n] < 0)
|
||||||
openf[n] = create(argv[0], OWRITE, 0666);
|
openf[n] = ocreate(argv[0], OWRITE, 0666);
|
||||||
seek(openf[n], 0L, 2);
|
seek(openf[n], 0L, 2);
|
||||||
} else
|
} else
|
||||||
openf[n] = create(argv[0], OWRITE, 0666);
|
openf[n] = ocreate(argv[0], OWRITE, 0666);
|
||||||
if(openf[n] < 0) {
|
if(openf[n] < 0) {
|
||||||
fprint(2, "tee: cannot open %s: %r\n", argv[0]);
|
fprint(2, "tee: cannot open %s: %r\n", argv[0]);
|
||||||
} else
|
} else
|
||||||
|
@ -38,7 +38,7 @@ main(int argc, char **argv)
|
|||||||
case 'c':
|
case 'c':
|
||||||
nocreate = 1;
|
nocreate = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ touch(int nocreate, char *name)
|
|||||||
fprint(2, "touch: %s: cannot wstat: %r\n", name);
|
fprint(2, "touch: %s: cannot wstat: %r\n", name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if((fd = create(name, OREAD|OEXCL, 0666)) < 0){
|
if((fd = create(name, OREAD, 0666)) < 0){
|
||||||
fprint(2, "touch: %s: cannot create: %r\n", name);
|
fprint(2, "touch: %s: cannot create: %r\n", name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ static void
|
|||||||
fulfill(Req *req, Event *e)
|
fulfill(Req *req, Event *e)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
n = e->len;
|
n = e->len;
|
||||||
if(n > req->ifcall.count)
|
if(n > req->ifcall.count)
|
||||||
n = req->ifcall.count;
|
n = req->ifcall.count;
|
||||||
@ -124,7 +124,7 @@ static void
|
|||||||
pushevent(Dev *d, char *data)
|
pushevent(Dev *d, char *data)
|
||||||
{
|
{
|
||||||
Event *e;
|
Event *e;
|
||||||
|
|
||||||
qlock(&evlock);
|
qlock(&evlock);
|
||||||
e = evlast;
|
e = evlast;
|
||||||
evlast = emallocz(sizeof(Event), 1);
|
evlast = emallocz(sizeof(Event), 1);
|
||||||
@ -225,7 +225,7 @@ formatdev(Dev *d, int type)
|
|||||||
Usbdev *u = d->usb;
|
Usbdev *u = d->usb;
|
||||||
return smprint("%s %d %.4x %.4x %.6lx %s\n",
|
return smprint("%s %d %.4x %.4x %.6lx %s\n",
|
||||||
type ? "detach" : "attach",
|
type ? "detach" : "attach",
|
||||||
d->id, u->vid, u->did, u->csp,
|
d->id, u->vid, u->did, u->csp,
|
||||||
d->hname != nil ? d->hname : "");
|
d->hname != nil ? d->hname : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ enumerate(Event **l)
|
|||||||
Port *p;
|
Port *p;
|
||||||
Dev *d;
|
Dev *d;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(h = hubs; h != nil; h = h->next){
|
for(h = hubs; h != nil; h = h->next){
|
||||||
for(i = 1; i <= h->nport; i++){
|
for(i = 1; i <= h->nport; i++){
|
||||||
p = &h->port[i];
|
p = &h->port[i];
|
||||||
@ -447,7 +447,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
busyfd = create("/env/usbbusy", ORCLOSE, 0600);
|
busyfd = ocreate("/env/usbbusy", ORCLOSE, 0600);
|
||||||
quotefmtinstall();
|
quotefmtinstall();
|
||||||
initevent();
|
initevent();
|
||||||
rfork(RFNOTEG);
|
rfork(RFNOTEG);
|
||||||
|
@ -609,7 +609,8 @@ faultamd64(Ureg* ureg, void* _1)
|
|||||||
insyscall = up->insyscall;
|
insyscall = up->insyscall;
|
||||||
up->insyscall = 1;
|
up->insyscall = 1;
|
||||||
if(iskaddr(addr)){
|
if(iskaddr(addr)){
|
||||||
print("kaddr %#llux pc %#p\n", addr, ureg->ip); prflush();
|
print("kaddr %#llux pc %#p\n", addr, ureg->ip);
|
||||||
|
// prflush();
|
||||||
dumpregs(ureg);
|
dumpregs(ureg);
|
||||||
}
|
}
|
||||||
if(fault(addr, ureg->ip, ftype) < 0){
|
if(fault(addr, ureg->ip, ftype) < 0){
|
||||||
|
@ -30,7 +30,7 @@ savelogsproc(void)
|
|||||||
|
|
||||||
out = open("/sys/log/kernel", OWRITE);
|
out = open("/sys/log/kernel", OWRITE);
|
||||||
if(out < 0){
|
if(out < 0){
|
||||||
out = create("/sys/log/kernel", OWRITE, 0600);
|
out = ocreate("/sys/log/kernel", OWRITE, 0600);
|
||||||
if(out < 0){
|
if(out < 0){
|
||||||
fprint(2, "savelogs: cannot create /sys/log/kernel: %r\n");
|
fprint(2, "savelogs: cannot create /sys/log/kernel: %r\n");
|
||||||
return;
|
return;
|
||||||
@ -139,7 +139,7 @@ setenv(char *name, char *val)
|
|||||||
char ename[64];
|
char ename[64];
|
||||||
|
|
||||||
snprint(ename, sizeof ename, "#e/%s", name);
|
snprint(ename, sizeof ename, "#e/%s", name);
|
||||||
f = create(ename, OWRITE, 0666);
|
f = ocreate(ename, OWRITE, 0666);
|
||||||
if(f < 0){
|
if(f < 0){
|
||||||
fprint(2, "create %s: %r\n", ename);
|
fprint(2, "create %s: %r\n", ename);
|
||||||
return;
|
return;
|
||||||
@ -162,7 +162,7 @@ srvcreate(char *name, int fd)
|
|||||||
srvname = name;
|
srvname = name;
|
||||||
|
|
||||||
snprint(buf, sizeof buf, "#s/%s", srvname);
|
snprint(buf, sizeof buf, "#s/%s", srvname);
|
||||||
f = create(buf, OWRITE, 0600);
|
f = ocreate(buf, OWRITE, 0600);
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
fatal(buf);
|
fatal(buf);
|
||||||
sprint(buf, "%d", fd);
|
sprint(buf, "%d", fd);
|
||||||
|
@ -1222,7 +1222,7 @@ namec(char *aname, int amode, int omode, int perm)
|
|||||||
Elemlist e;
|
Elemlist e;
|
||||||
Rune r;
|
Rune r;
|
||||||
Mhead *mh;
|
Mhead *mh;
|
||||||
char *createerr, tmperrbuf[ERRMAX];
|
char tmperrbuf[ERRMAX];
|
||||||
char *name;
|
char *name;
|
||||||
Dev *dev;
|
Dev *dev;
|
||||||
|
|
||||||
@ -1309,13 +1309,7 @@ namec(char *aname, int amode, int omode, int perm)
|
|||||||
dev = devtabget(r, 1); //XDYNX
|
dev = devtabget(r, 1); //XDYNX
|
||||||
if(dev == nil)
|
if(dev == nil)
|
||||||
error(Ebadsharp);
|
error(Ebadsharp);
|
||||||
//if(waserror()){
|
|
||||||
// devtabdecr(dev);
|
|
||||||
// nexterror();
|
|
||||||
//}
|
|
||||||
c = dev->attach(nil, nil, up->genbuf+n, 0);
|
c = dev->attach(nil, nil, up->genbuf+n, 0);
|
||||||
//poperror();
|
|
||||||
//devtabdecr(dev);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1403,7 +1397,6 @@ namec(char *aname, int amode, int omode, int perm)
|
|||||||
case Aaccess:
|
case Aaccess:
|
||||||
case Aremove:
|
case Aremove:
|
||||||
case Aopen:
|
case Aopen:
|
||||||
Open:
|
|
||||||
/* save&update the name; domount might change c */
|
/* save&update the name; domount might change c */
|
||||||
path = c->path;
|
path = c->path;
|
||||||
incref(&path->r);
|
incref(&path->r);
|
||||||
@ -1482,58 +1475,13 @@ namec(char *aname, int amode, int omode, int perm)
|
|||||||
case Acreate:
|
case Acreate:
|
||||||
/*
|
/*
|
||||||
* We've already walked all but the last element.
|
* We've already walked all but the last element.
|
||||||
* If the last exists, try to open it OTRUNC.
|
* If the last exists just give up.
|
||||||
* If omode&OEXCL is set, just give up.
|
|
||||||
*/
|
*/
|
||||||
e.nelems++;
|
e.nelems++;
|
||||||
e.nerror++;
|
e.nerror++;
|
||||||
if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) == 0){
|
if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) == 0)
|
||||||
if(omode&OEXCL)
|
error(Eexist);
|
||||||
error(Eexist);
|
|
||||||
omode |= OTRUNC;
|
|
||||||
goto Open;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The semantics of the create(2) system call are that if the
|
|
||||||
* file exists and can be written, it is to be opened with truncation.
|
|
||||||
* On the other hand, the create(5) message fails if the file exists.
|
|
||||||
* If we get two create(2) calls happening simultaneously,
|
|
||||||
* they might both get here and send create(5) messages, but only
|
|
||||||
* one of the messages will succeed. To provide the expected create(2)
|
|
||||||
* semantics, the call with the failed message needs to try the above
|
|
||||||
* walk again, opening for truncation. This correctly solves the
|
|
||||||
* create/create race, in the sense that any observable outcome can
|
|
||||||
* be explained as one happening before the other.
|
|
||||||
* The create/create race is quite common. For example, it happens
|
|
||||||
* when two rc subshells simultaneously update the same
|
|
||||||
* environment variable.
|
|
||||||
*
|
|
||||||
* The implementation still admits a create/create/remove race:
|
|
||||||
* (A) walk to file, fails
|
|
||||||
* (B) walk to file, fails
|
|
||||||
* (A) create file, succeeds, returns
|
|
||||||
* (B) create file, fails
|
|
||||||
* (A) remove file, succeeds, returns
|
|
||||||
* (B) walk to file, return failure.
|
|
||||||
*
|
|
||||||
* This is hardly as common as the create/create race, and is really
|
|
||||||
* not too much worse than what might happen if (B) got a hold of a
|
|
||||||
* file descriptor and then the file was removed -- either way (B) can't do
|
|
||||||
* anything with the result of the create call. So we don't care about this race.
|
|
||||||
*
|
|
||||||
* Applications that care about more fine-grained decision of the races
|
|
||||||
* can use the OEXCL flag to get at the underlying create(5) semantics;
|
|
||||||
* by default we provide the common case.
|
|
||||||
*
|
|
||||||
* We need to stay behind the mount point in case we
|
|
||||||
* need to do the first walk again (should the create fail).
|
|
||||||
*
|
|
||||||
* We also need to cross the mount point and find the directory
|
|
||||||
* in the union in which we should be creating.
|
|
||||||
*
|
|
||||||
* The channel staying behind is c, the one moving forward is cnew.
|
|
||||||
*/
|
|
||||||
mh = nil;
|
mh = nil;
|
||||||
cnew = nil; /* is this assignment necessary? */
|
cnew = nil; /* is this assignment necessary? */
|
||||||
if(!waserror()){ /* try create */
|
if(!waserror()){ /* try create */
|
||||||
@ -1555,7 +1503,7 @@ namec(char *aname, int amode, int omode, int perm)
|
|||||||
cnew->path = c->path;
|
cnew->path = c->path;
|
||||||
incref(&cnew->path->r);
|
incref(&cnew->path->r);
|
||||||
|
|
||||||
cnew = cnew->dev->create(cnew, e.elems[e.nelems-1], omode&~(OEXCL|OCEXEC), perm);
|
cnew = cnew->dev->create(cnew, e.elems[e.nelems-1], omode&~(OCEXEC), perm);
|
||||||
poperror();
|
poperror();
|
||||||
if(omode & OCEXEC)
|
if(omode & OCEXEC)
|
||||||
cnew->flag |= CCEXEC;
|
cnew->flag |= CCEXEC;
|
||||||
@ -1570,19 +1518,7 @@ namec(char *aname, int amode, int omode, int perm)
|
|||||||
/* create failed */
|
/* create failed */
|
||||||
cclose(cnew);
|
cclose(cnew);
|
||||||
putmhead(mh);
|
putmhead(mh);
|
||||||
if(omode & OEXCL)
|
nexterror();
|
||||||
nexterror();
|
|
||||||
/* save error */
|
|
||||||
createerr = up->errstr;
|
|
||||||
up->errstr = tmperrbuf;
|
|
||||||
/* note: we depend that walk does not error */
|
|
||||||
if(walk(&c, e.elems+e.nelems-1, 1, nomount, nil) < 0){
|
|
||||||
up->errstr = createerr;
|
|
||||||
error(createerr); /* report true error */
|
|
||||||
}
|
|
||||||
up->errstr = createerr;
|
|
||||||
omode |= OTRUNC;
|
|
||||||
goto Open;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
panic("unknown namec access %d", amode);
|
panic("unknown namec access %d", amode);
|
||||||
|
@ -498,7 +498,7 @@ ninep2mode(int omode9p)
|
|||||||
if((omode9p&~0xff) || (omode9p&NP_OZEROES))
|
if((omode9p&~0xff) || (omode9p&NP_OZEROES))
|
||||||
error("invalid 9P2000 open mode");
|
error("invalid 9P2000 open mode");
|
||||||
|
|
||||||
switch(omode9p & ~(NP_OTRUNC|NP_ORCLOSE)){
|
switch(omode9p & ~(NP_OTRUNC|NP_ORCLOSE|NP_OCEXEC)){
|
||||||
case NP_OREAD:
|
case NP_OREAD:
|
||||||
return OREAD;
|
return OREAD;
|
||||||
case NP_OWRITE:
|
case NP_OWRITE:
|
||||||
@ -513,10 +513,12 @@ ninep2mode(int omode9p)
|
|||||||
default:
|
default:
|
||||||
error("invalid 9P2000 open mode");
|
error("invalid 9P2000 open mode");
|
||||||
}
|
}
|
||||||
if(omode9p & NP_OTRUNC)
|
if(omode9p & NP_OCEXEC)
|
||||||
mode |= OTRUNC;
|
mode |= OCEXEC;
|
||||||
if(omode9p & NP_ORCLOSE)
|
if(omode9p & NP_ORCLOSE)
|
||||||
mode |= ORCLOSE;
|
mode |= ORCLOSE;
|
||||||
|
if(omode9p & NP_OTRUNC)
|
||||||
|
mode |= OTRUNC;
|
||||||
|
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
@ -542,6 +544,8 @@ mode2ninep(unsigned long mode)
|
|||||||
omode9p |= NP_OEXEC;
|
omode9p |= NP_OEXEC;
|
||||||
if(mode & ORCLOSE)
|
if(mode & ORCLOSE)
|
||||||
omode9p |= NP_ORCLOSE;
|
omode9p |= NP_ORCLOSE;
|
||||||
|
if(mode & OCEXEC)
|
||||||
|
omode9p |= NP_OCEXEC;
|
||||||
|
|
||||||
/* this is an approssimation: in Jehanne this bit might means
|
/* this is an approssimation: in Jehanne this bit might means
|
||||||
* something different to a server, but then the
|
* something different to a server, but then the
|
||||||
|
@ -245,11 +245,9 @@ void
|
|||||||
prflush(void)
|
prflush(void)
|
||||||
{
|
{
|
||||||
unsigned long now;
|
unsigned long now;
|
||||||
// uint32_t now;
|
|
||||||
|
|
||||||
now = sys->ticks;
|
now = sys->ticks;
|
||||||
while(consactive())
|
while(consactive())
|
||||||
// uartpush();
|
|
||||||
if(sys->ticks - now >= 30*HZ)
|
if(sys->ticks - now >= 30*HZ)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -365,7 +363,6 @@ print(char *fmt, ...)
|
|||||||
n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf;
|
n = vseprint(buf, buf+sizeof(buf), fmt, arg) - buf;
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
putstrn(buf, n);
|
putstrn(buf, n);
|
||||||
if(strchr(buf, '\n') != nil)prflush();
|
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -452,7 +449,7 @@ panic(char *fmt, ...)
|
|||||||
buf[n] = '\n';
|
buf[n] = '\n';
|
||||||
putstrn(buf, n+1);
|
putstrn(buf, n+1);
|
||||||
// dumpstack();
|
// dumpstack();
|
||||||
prflush();
|
// prflush();
|
||||||
// dump();
|
// dump();
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -157,7 +157,7 @@ srvcreate(Chan *c, char *name, unsigned long omode, unsigned long perm)
|
|||||||
{
|
{
|
||||||
Srv *sp;
|
Srv *sp;
|
||||||
|
|
||||||
if(openmode(omode & ~ORCLOSE) != OWRITE){
|
if(openmode(omode & ~(ORCLOSE|OTRUNC)) != OWRITE){
|
||||||
errorf("srvcreate: omode %#p openmode %#p", omode, openmode(omode & ~ORCLOSE));
|
errorf("srvcreate: omode %#p openmode %#p", omode, openmode(omode & ~ORCLOSE));
|
||||||
//error(Eperm);
|
//error(Eperm);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,6 @@ extern uint64_t strtoull(char*, char**, int);
|
|||||||
|
|
||||||
/* OPEN MODES: Popular flags among filesystems */
|
/* OPEN MODES: Popular flags among filesystems */
|
||||||
#define OTRUNC 0x0100 /* or'ed in (except for exec), truncate file first */
|
#define OTRUNC 0x0100 /* or'ed in (except for exec), truncate file first */
|
||||||
#define OEXCL 0x0200 /* or'ed in, exclusive create */
|
|
||||||
|
|
||||||
#define NCONT 0 /* continue after note */
|
#define NCONT 0 /* continue after note */
|
||||||
#define NDFLT 1 /* terminate after note */
|
#define NDFLT 1 /* terminate after note */
|
||||||
|
@ -1030,7 +1030,7 @@ syscreate(char* aname, uint32_t omode, uint32_t perm)
|
|||||||
int fd;
|
int fd;
|
||||||
Chan *c;
|
Chan *c;
|
||||||
|
|
||||||
openmode(omode & ~OEXCL); /* error check only; OEXCL okay here */
|
openmode(omode); /* error check only; OEXCL okay here */
|
||||||
c = nil;
|
c = nil;
|
||||||
if(waserror()) {
|
if(waserror()) {
|
||||||
if(c != nil)
|
if(c != nil)
|
||||||
|
@ -410,7 +410,7 @@ sopen(Srv *srv, Req *r)
|
|||||||
respond(r, Ebotch);
|
respond(r, Ebotch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if((r->fid->qid.type&QTDIR) && (r->ifcall.mode&~ORCLOSE) != NP_OREAD){
|
if((r->fid->qid.type&QTDIR) && (r->ifcall.mode&~NP_ORCLOSE) != NP_OREAD){
|
||||||
respond(r, Eisdir);
|
respond(r, Eisdir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -537,7 +537,7 @@ sread(Srv *srv, Req *r)
|
|||||||
r->ifcall.count = srv->msize - IOHDRSZ;
|
r->ifcall.count = srv->msize - IOHDRSZ;
|
||||||
r->rbuf = emalloc9p(r->ifcall.count);
|
r->rbuf = emalloc9p(r->ifcall.count);
|
||||||
r->ofcall.data = r->rbuf;
|
r->ofcall.data = r->rbuf;
|
||||||
o = r->fid->omode & 7;
|
o = r->fid->omode & 3;
|
||||||
if(o != NP_OREAD && o != NP_ORDWR && o != NP_OEXEC){
|
if(o != NP_OREAD && o != NP_ORDWR && o != NP_OEXEC){
|
||||||
respond(r, Ebotch);
|
respond(r, Ebotch);
|
||||||
return;
|
return;
|
||||||
@ -579,7 +579,7 @@ swrite(Srv *srv, Req *r)
|
|||||||
}
|
}
|
||||||
if(r->ifcall.count > srv->msize - IOHDRSZ)
|
if(r->ifcall.count > srv->msize - IOHDRSZ)
|
||||||
r->ifcall.count = srv->msize - IOHDRSZ;
|
r->ifcall.count = srv->msize - IOHDRSZ;
|
||||||
o = r->fid->omode & 7;
|
o = r->fid->omode & 3;
|
||||||
if(o != NP_OWRITE && o != NP_ORDWR){
|
if(o != NP_OWRITE && o != NP_ORDWR){
|
||||||
snprint(e, sizeof e, "write on fid with open mode 0x%ux", r->fid->omode);
|
snprint(e, sizeof e, "write on fid with open mode 0x%ux", r->fid->omode);
|
||||||
respond(r, e);
|
respond(r, e);
|
||||||
@ -952,7 +952,7 @@ postfd(char *name, int pfd)
|
|||||||
snprint(buf, sizeof buf, "/srv/%s", name);
|
snprint(buf, sizeof buf, "/srv/%s", name);
|
||||||
if(chatty9p)
|
if(chatty9p)
|
||||||
fprint(2, "postfd %s\n", buf);
|
fprint(2, "postfd %s\n", buf);
|
||||||
fd = create(buf, OWRITE|ORCLOSE|OCEXEC, 0600);
|
fd = ocreate(buf, OWRITE|ORCLOSE|OCEXEC, 0600);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
if(chatty9p)
|
if(chatty9p)
|
||||||
fprint(2, "create fails: %r\n");
|
fprint(2, "create fails: %r\n");
|
||||||
@ -981,7 +981,7 @@ sharefd(char *name, char *desc, int pfd)
|
|||||||
snprint(buf, sizeof buf, "#σc/%s/%s", name, desc);
|
snprint(buf, sizeof buf, "#σc/%s/%s", name, desc);
|
||||||
if(chatty9p)
|
if(chatty9p)
|
||||||
fprint(2, "sharefd %s\n", buf);
|
fprint(2, "sharefd %s\n", buf);
|
||||||
fd = create(buf, OWRITE, 0600);
|
fd = ocreate(buf, OWRITE, 0600);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
if(chatty9p)
|
if(chatty9p)
|
||||||
fprint(2, "create fails: %r\n");
|
fprint(2, "create fails: %r\n");
|
||||||
|
@ -340,7 +340,7 @@ setenv(char *name, char *val)
|
|||||||
int32_t s;
|
int32_t s;
|
||||||
|
|
||||||
sprint(ename, "#e/%s", name);
|
sprint(ename, "#e/%s", name);
|
||||||
f = create(ename, OWRITE, 0664);
|
f = ocreate(ename, OWRITE, 0664);
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
return -1;
|
return -1;
|
||||||
s = strlen(val);
|
s = strlen(val);
|
||||||
|
@ -133,7 +133,7 @@ Bopen(char *name, int mode)
|
|||||||
f = open(name, mode);
|
f = open(name, mode);
|
||||||
break;
|
break;
|
||||||
case OWRITE:
|
case OWRITE:
|
||||||
f = create(name, mode, 0666);
|
f = ocreate(name, mode, 0666);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
|
@ -15,7 +15,17 @@ access(const char *name, int mode)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
Dir *db;
|
Dir *db;
|
||||||
mode &= AMASK;
|
|
||||||
|
static char omode[] = {
|
||||||
|
0,
|
||||||
|
OEXEC,
|
||||||
|
OWRITE,
|
||||||
|
ORDWR,
|
||||||
|
OREAD,
|
||||||
|
OEXEC, /* only approximate */
|
||||||
|
ORDWR,
|
||||||
|
ORDWR /* only approximate */
|
||||||
|
};
|
||||||
|
|
||||||
if(mode == AEXIST){
|
if(mode == AEXIST){
|
||||||
db = dirstat(name);
|
db = dirstat(name);
|
||||||
@ -24,7 +34,7 @@ access(const char *name, int mode)
|
|||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd = open(name, mode);
|
fd = open(name, omode[mode&7]);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
69
sys/src/lib/c/9sys/ocreate.c
Normal file
69
sys/src/lib/c/9sys/ocreate.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Jehanne.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Giacomo Tesio <giacomo@tesio.it>
|
||||||
|
*
|
||||||
|
* Jehanne is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 2 of the License.
|
||||||
|
*
|
||||||
|
* Jehanne is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
|
||||||
|
/* ocreate works like the Plan 9 create(2) syscall, but with different races.
|
||||||
|
* In Plan 9 tjere os a race due to the different behaviour between the
|
||||||
|
* create syscall and the Tcreate message in 9P2000 when the file already exists:
|
||||||
|
* see https://github.com/brho/plan9/blob/master/sys/src/9/port/chan.c#L1564-L1603
|
||||||
|
* for details.
|
||||||
|
*
|
||||||
|
* In Jehanne the create syscall fails on existing files just like the Tcreate message.
|
||||||
|
* However the Plan 9/UNIX semantic is often useful, thus ocreate mimic it in userspace.
|
||||||
|
* As wisely noted by Charles Forsyth, such implementation introduce a different race
|
||||||
|
* due to the multiple evaluations of the path: on concurrent namespace changes, the
|
||||||
|
* different syscalls here could be handled by different devices/fileservers.
|
||||||
|
* However, given the user is responsible of such namespace changes, we prefer this race
|
||||||
|
* to the original Plan 9 one.
|
||||||
|
*
|
||||||
|
* For more info see http://marc.info/?t=146412533100003&r=1&w=2
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ocreate(const char *path, unsigned int omode, unsigned int perm)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
Dir *s;
|
||||||
|
|
||||||
|
fd = open(path, omode|OTRUNC);
|
||||||
|
if(fd < 0){
|
||||||
|
fd = create(path, omode, perm);
|
||||||
|
if(fd < 0){
|
||||||
|
fd = open(path, omode|OTRUNC);
|
||||||
|
if(fd < 0)
|
||||||
|
goto Done;
|
||||||
|
} else {
|
||||||
|
goto Done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s = dirfstat(fd);
|
||||||
|
if(s == nil){
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(s->mode != perm){
|
||||||
|
s->mode = perm;
|
||||||
|
dirfwstat(fd, s); /* we ignore the return value, the device/server is allowed to ignore us */
|
||||||
|
}
|
||||||
|
free(s);
|
||||||
|
|
||||||
|
Done:
|
||||||
|
return fd;
|
||||||
|
}
|
@ -24,12 +24,12 @@ putenv(const char *name, const char *val)
|
|||||||
snprint(ename, sizeof ename, "/env/%s", name);
|
snprint(ename, sizeof ename, "/env/%s", name);
|
||||||
if(strcmp(ename+5, name) != 0)
|
if(strcmp(ename+5, name) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
f = create(ename, OWRITE, 0664);
|
f = ocreate(ename, OWRITE, 0664);
|
||||||
if(f < 0){
|
if(f < 0){
|
||||||
/* try with #e, in case of a previous rfork(RFCNAMEG)
|
/* try with #e, in case of a previous rfork(RFCNAMEG)
|
||||||
*/
|
*/
|
||||||
snprint(ename, sizeof ename, "#e/%s", name);
|
snprint(ename, sizeof ename, "#e/%s", name);
|
||||||
f = create(ename, OWRITE, 0664);
|
f = ocreate(ename, OWRITE, 0664);
|
||||||
if(f < 0)
|
if(f < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
"9sys/getwd.c",
|
"9sys/getwd.c",
|
||||||
"9sys/iounit.c",
|
"9sys/iounit.c",
|
||||||
"9sys/nulldir.c",
|
"9sys/nulldir.c",
|
||||||
|
"9sys/ocreate.c",
|
||||||
"9sys/pipe.c",
|
"9sys/pipe.c",
|
||||||
"9sys/postnote.c",
|
"9sys/postnote.c",
|
||||||
"9sys/privalloc.c",
|
"9sys/privalloc.c",
|
||||||
|
@ -102,7 +102,7 @@ geninitdraw(char *devdir, void(*error)(Display*, char*),
|
|||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
read(fd, display->oldlabel, (sizeof display->oldlabel)-1);
|
read(fd, display->oldlabel, (sizeof display->oldlabel)-1);
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = create(buf, OWRITE, 0666);
|
fd = ocreate(buf, OWRITE, 0666);
|
||||||
if(fd >= 0){
|
if(fd >= 0){
|
||||||
write(fd, label, strlen(label));
|
write(fd, label, strlen(label));
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -20,7 +20,7 @@ plumbopen(char *name, int omode)
|
|||||||
|
|
||||||
if(name[0] == '/')
|
if(name[0] == '/')
|
||||||
return open(name, omode);
|
return open(name, omode);
|
||||||
|
|
||||||
/* find elusive plumber */
|
/* find elusive plumber */
|
||||||
if(access("/mnt/plumb/send", AWRITE) >= 0)
|
if(access("/mnt/plumb/send", AWRITE) >= 0)
|
||||||
plumber = "/mnt/plumb";
|
plumber = "/mnt/plumb";
|
||||||
@ -51,7 +51,7 @@ plumbopen(char *name, int omode)
|
|||||||
|
|
||||||
/* try creating port; used by non-standard plumb implementations */
|
/* try creating port; used by non-standard plumb implementations */
|
||||||
rerrstr(err, sizeof err);
|
rerrstr(err, sizeof err);
|
||||||
fd = create(buf, omode, 0600);
|
fd = ocreate(buf, omode, 0600);
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
errstr(err, sizeof err);
|
errstr(err, sizeof err);
|
||||||
|
@ -42,13 +42,13 @@ FILE *freopen(const char *name, const char *mode, FILE *f){
|
|||||||
f->fd=open(name, (*mode == '+'? ORDWR: OREAD));
|
f->fd=open(name, (*mode == '+'? ORDWR: OREAD));
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
f->fd=create(name, (*mode == '+'? ORDWR: OWRITE), 0666);
|
f->fd=ocreate(name, (*mode == '+'? ORDWR: OWRITE), 0666);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
m = (*mode == '+'? ORDWR: OWRITE);
|
m = (*mode == '+'? ORDWR: OWRITE);
|
||||||
f->fd=open(name, m);
|
f->fd=open(name, m);
|
||||||
if(f->fd<0)
|
if(f->fd<0)
|
||||||
f->fd=create(name, m, 0666);
|
f->fd=ocreate(name, m, 0666);
|
||||||
seek(f->fd, 0LL, 2);
|
seek(f->fd, 0LL, 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user