提交 15421863 创建 作者: rsc's avatar rsc

allow long names again

上级 0517a730
...@@ -504,8 +504,8 @@ namei(char *path, int mode, uint *ret_off, ...@@ -504,8 +504,8 @@ namei(char *path, int mode, uint *ret_off,
uint off, dev; uint off, dev;
struct buf *bp; struct buf *bp;
struct dirent *ep; struct dirent *ep;
int i, atend; int i, l, atend;
unsigned ninum; uint ninum;
if(ret_off) if(ret_off)
*ret_off = 0xffffffff; *ret_off = 0xffffffff;
...@@ -544,10 +544,9 @@ namei(char *path, int mode, uint *ret_off, ...@@ -544,10 +544,9 @@ namei(char *path, int mode, uint *ret_off,
for(i = 0; cp[i] != 0 && cp[i] != '/'; i++) for(i = 0; cp[i] != 0 && cp[i] != '/'; i++)
; ;
if(i > DIRSIZ){ l = i;
iput(dp); if(i > DIRSIZ)
return 0; l = DIRSIZ;
}
for(off = 0; off < dp->size; off += BSIZE){ for(off = 0; off < dp->size; off += BSIZE){
bp = bread(dp->dev, bmap(dp, off / BSIZE)); bp = bread(dp->dev, bmap(dp, off / BSIZE));
...@@ -556,8 +555,8 @@ namei(char *path, int mode, uint *ret_off, ...@@ -556,8 +555,8 @@ namei(char *path, int mode, uint *ret_off,
ep++){ ep++){
if(ep->inum == 0) if(ep->inum == 0)
continue; continue;
if(memcmp(cp, ep->name, i) == 0 && if(memcmp(cp, ep->name, l) == 0 &&
(i == DIRSIZ || ep->name[i]== 0)){ (l == DIRSIZ || ep->name[l]== 0)){
// entry matches path element // entry matches path element
off += (uchar*)ep - bp->data; off += (uchar*)ep - bp->data;
ninum = ep->inum; ninum = ep->inum;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论