ref: 42224f7e5bcde0ae9a84c91975b681296118d207
parent: f0303b65cabce1a3cdf2781c952c94a3f1aca310
author: cinap_lenrek <[email protected]>
date: Thu Mar 14 16:55:16 EDT 2013
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.
--- a/sys/src/cmd/hjfs/fs1.c
+++ b/sys/src/cmd/hjfs/fs1.c
@@ -972,46 +972,46 @@
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)
+ 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;
- 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;
- 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);
}
}
}