summaryrefslogtreecommitdiff
path: root/sys/src/cmd/hjfs/fs1.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-03-14 20:55:16 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-03-14 20:55:16 +0100
commit42224f7e5bcde0ae9a84c91975b681296118d207 (patch)
treee0086ca21f48a86553bda73e745dea183479d037 /sys/src/cmd/hjfs/fs1.c
parentf0303b65cabce1a3cdf2781c952c94a3f1aca310 (diff)
hjfs: fix the megashit
aiju → what is this huge if(d != nil) {} megashit if getdent() fails in newentry() then return immidiately and dont override the error string.
Diffstat (limited to 'sys/src/cmd/hjfs/fs1.c')
-rw-r--r--sys/src/cmd/hjfs/fs1.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/sys/src/cmd/hjfs/fs1.c b/sys/src/cmd/hjfs/fs1.c
index bd9e87036..ac37eefb0 100644
--- a/sys/src/cmd/hjfs/fs1.c
+++ b/sys/src/cmd/hjfs/fs1.c
@@ -972,46 +972,46 @@ newentry(Fs *fs, Loc *l, Buf *b, char *name, FLoc *res, int dump)
int j, sj;
Buf *c;
- si = sj = -1;
d = getdent(l, b);
- if(d != nil){
- for(i = 0; i < d->size; i++){
- if(getblk(fs, l, b, i, &r, GBREAD) <= 0)
- continue;
- c = getbuf(fs->d, r, TDENTRY, 0);
- if(c == nil)
+ if(d == nil)
+ return -1;
+ si = sj = -1;
+ for(i = 0; i < d->size; i++){
+ if(getblk(fs, l, b, i, &r, GBREAD) <= 0)
+ continue;
+ c = getbuf(fs->d, r, TDENTRY, 0);
+ if(c == nil)
+ continue;
+ for(j = 0; j < DEPERBLK; j++){
+ dd = &c->de[j];
+ if((dd->mode & DGONE) != 0)
continue;
- for(j = 0; j < DEPERBLK; j++){
- dd = &c->de[j];
- if((dd->mode & DGONE) != 0)
- continue;
- if((dd->mode & DALLOC) != 0){
- if(strcmp(dd->name, name) == 0){
- werrstr(Eexists);
- putbuf(c);
- return 0;
- }
- continue;
+ if((dd->mode & DALLOC) != 0){
+ if(strcmp(dd->name, name) == 0){
+ werrstr(Eexists);
+ putbuf(c);
+ return 0;
}
- if(si != -1 || haveloc(fs, r, j, l))
- continue;
- si = i;
- sj = j;
+ continue;
}
- putbuf(c);
+ if(si != -1 || haveloc(fs, r, j, l))
+ continue;
+ si = i;
+ sj = j;
}
- if(si == -1 && i == d->size){
- if(getblk(fs, l, b, i, &r, GBCREATE) >= 0){
- c = getbuf(fs->d, r, TDENTRY, 1);
- if(c != nil){
- si = i;
- sj = 0;
- d->size = i+1;
- b->op |= BDELWRI;
- memset(c->de, 0, sizeof(c->de));
- c->op |= BDELWRI;
- putbuf(c);
- }
+ putbuf(c);
+ }
+ if(si == -1 && i == d->size){
+ if(getblk(fs, l, b, i, &r, GBCREATE) >= 0){
+ c = getbuf(fs->d, r, TDENTRY, 1);
+ if(c != nil){
+ si = i;
+ sj = 0;
+ d->size = i+1;
+ b->op |= BDELWRI;
+ memset(c->de, 0, sizeof(c->de));
+ c->op |= BDELWRI;
+ putbuf(c);
}
}
}