static int find(char *path, struct iob *file) { char *q; char c; int n = 0; #if CHECK_CAREFULLY if (path==NULL || *path=='\0') { printf("null path\n"); return (0); } #endif CHECK_CAREFULLY if (openi((ino_t) ROOTINO, file) < 0) { #if SYS_MESSAGES error("bad root inode\n"); #endif return (0); } while (*path) { while (*path == '/') path++; q = path; while(*q != '/' && *q != '\0') q++; c = *q; *q = '\0'; if (q == path) path = "." ; /* "/" means "/." */ if ((n = dlook(path, file)) != 0) { if (c == '\0') break; if (openi(n, file) < 0) { *q = c; return (0); } *q = c; path = q; continue; } else { *q = c; return (0); } } return (n); }
static ino_t find(char *path, struct iob *file) { char *q; char c; ino_t n; if (path == NULL || *path == '\0') return (0); if (opendir(root_ino, file)) return (0); while (*path) { while (*path == '/') path++; q = path; while (*q != '/' && *q != '\0') q++; c = *q; *q = '\0'; if ((n = dlook(path, file)) != 0) { if (c == '\0') break; if (opendir(n, file)) return (0); *q = c; path = q; continue; } else { return (0); } } return ((ino_t)n); }