diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-11-18 12:00:13 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-11-18 12:00:13 +0100 |
commit | bcaf52ebcde1933f4891c3e6f994951aa7c012f7 (patch) | |
tree | 561e56efcd1ac83f128667cda0ddbccc0e57d3ae /sys/src/cmd/hjfs/main.c | |
parent | 28452d3fe553c1c61321d1973ee5db57b4dcc3a5 (diff) |
hjfs: ORCLOSE parent check, estrdup / erealloc, CHFNOPERM consistency
check for write premission in the parent directory
for open with ORCLOSE. honor CHFNOPERM not just in
chancreat(), pikeshedd the error handling. added
estrdup()/erealloc() that call sysfatal instead
of returning nil.
Diffstat (limited to 'sys/src/cmd/hjfs/main.c')
-rw-r--r-- | sys/src/cmd/hjfs/main.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/sys/src/cmd/hjfs/main.c b/sys/src/cmd/hjfs/main.c index 85c06ed6b..6a6c4697e 100644 --- a/sys/src/cmd/hjfs/main.c +++ b/sys/src/cmd/hjfs/main.c @@ -27,6 +27,26 @@ emalloc(int c) return v; } +void* +erealloc(void *v, int c) +{ + v = realloc(v, c); + if(v == 0) + sysfatal("realloc: %r"); + setrealloctag(v, getcallerpc(&c)); + return v; +} + +char* +estrdup(char *s) +{ + s = strdup(s); + if(s == 0) + sysfatal("strdup: %r"); + setmalloctag(s, getcallerpc(&s)); + return s; +} + ThrData * getthrdata(void) { @@ -88,8 +108,8 @@ threadmain(int argc, char **argv) case 'r': doream++; break; case 'S': flags |= FSNOPERM | FSCHOWN; break; case 's': stdio++; break; - case 'f': file = strdup(EARGF(usage())); break; - case 'n': service = strdup(EARGF(usage())); break; + case 'f': file = estrdup(EARGF(usage())); break; + case 'n': service = estrdup(EARGF(usage())); break; case 'm': nbuf = muldiv(atoi(EARGF(usage())), 1048576, sizeof(Buf)); if(nbuf < 10) |