* Convert a pathname into a pointer to
* an inode. Note that the inode is locked.
* func = function called to get next char of name
* &uchar if name is in user space
* &schar if name is in system space
* flag = 0 if name is sought
* 1 if name is to be created
* 2 if name is to be deleted
register struct inode
*dp
;
* If name starts with '/' start from
* root; otherwise start from current dir.
iget(dp
->i_dev
, dp
->i_number
);
if(c
== '\0' && flag
!= 0) {
* Here dp contains pointer
* to last component matched.
* If there is another component,
* dp must be a directory and
* must have x permission.
if((dp
->i_mode
&IFMT
) != IFDIR
) {
while(c
!='/' && c
!='\0' && u
.u_error
==0) {
if(cp
< &u
.u_dbuf
[DIRSIZ
])
while(cp
< &u
.u_dbuf
[DIRSIZ
])
* Set up to search a directory.
u
.u_count
= ldiv(dp
->i_size1
, DIRSIZ
+2);
* If at the end of the directory,
* the search failed. Report what
* is appropriate as per flag.
u
.u_offset
[1] = eo
-DIRSIZ
-2; else
* If offset is on a block boundary,
* read the next directory block.
* Release previous if it exists.
if((u
.u_offset
[1]&0777) == 0) {
bmap(dp
, ldiv(u
.u_offset
[1], 512)));
* Note first empty directory slot
* in eo for possible creat.
* String compare the directory entry
* and the current component.
* If they do not match, go back to eloop.
bcopy(bp
->b_addr
+(u
.u_offset
[1]&0777), &u
.u_dent
, (DIRSIZ
+2)/2);
u
.u_offset
[1] =+ DIRSIZ
+2;
if(u
.u_dent
.u_ino
== 0) {
for(cp
= &u
.u_dbuf
[0]; cp
< &u
.u_dbuf
[DIRSIZ
]; cp
++)
if(*cp
!= cp
[u
.u_dent
.u_name
- u
.u_dbuf
])
* Here a component matched in a directory.
* If there is more pathname, go back to
* cloop, otherwise return.
dp
= iget(bp
, u
.u_dent
.u_ino
);
* Return the next character from the
* kernel string pointed at by dirp.
return(*u
.u_dirp
++ & 0377);
* Return the next character from the
* user string pointed at by dirp.