1,7 → 1,42 |
/* This file contains the procedures that look up path names in the directory |
* system and determine the inode number that goes with a given path name. |
*/ |
/* |
* Copyright (c) 1987,1997, Prentice Hall |
* All rights reserved. |
* |
* Redistribution and use of the MINIX operating system in source and |
* binary forms, with or without modification, are permitted provided |
* that the following conditions are met: |
|
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
|
* - Redistributions in binary form must reproduce the above |
* copyright notice, this list of conditions and the following |
* disclaimer in the documentation and/or other materials provided |
* with the distribution. |
|
* - Neither the name of Prentice Hall nor the names of the software |
* authors or contributors may be used to endorse or promote |
* products derived from this software without specific prior |
* written permission. |
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND |
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
|
|
/* Methods: |
* eat_path: the 'main' routine of the path-to-inode conversion mechanism |
* last_dir: find the final directory on a given path |
41,19 → 76,20 |
if (sp->s_extend) { |
name_len = NAME_MAX_EX; |
} |
|
|
/* First open the path down to the final directory. */ |
if ( (ldip = last_dir(path, string, name_len)) == NIL_INODE) |
return NIL_INODE; /* we couldn't open final directory */ |
|
|
|
/* The path consisting only of "/" is a special case, check for it. */ |
if (string[0] == '\0') |
return ldip; |
|
|
/* Get final component of the path. */ |
rip = advance(ldip, string, name_len); |
put_inode(ldip); |
|
|
return rip; |
} |
|
88,6 → 124,7 |
/* Extract one component. */ |
if ( (new_name = get_name(path, string, string_length)) == (char*) 0) { |
put_inode(rip); /* bad path in user space */ |
|
return NIL_INODE; |
} |
if (*new_name == '\0') |
217,9 → 254,9 |
block_num_t b; |
|
/* If 'ldir_ptr' is not a pointer to a dir inode, error. */ |
if ((ldir_ptr->i_mode & I_TYPE) != I_DIRECTORY) |
if ((ldir_ptr->i_mode & I_TYPE) != I_DIRECTORY) { |
return FS_ENOTDIR; |
|
} |
r = OK; |
|
/* Step through the directory one block at a time. */ |
244,8 → 281,9 |
match = 1; |
} |
else { |
if (fs_strncmp(dp->d_name, string, NAME_MAX) == 0) |
if (fs_strncmp(dp->d_name, string, NAME_MAX) == 0) { |
match = 1; |
} |
} |
} |
|
280,9 → 318,9 |
block_num_t b; |
|
/* If 'ldir_ptr' is not a pointer to a dir inode, error. */ |
if ( (ldir_ptr->i_mode & I_TYPE) != I_DIRECTORY) |
if ( (ldir_ptr->i_mode & I_TYPE) != I_DIRECTORY) { |
return FS_ENOTDIR; |
|
} |
r = OK; |
|
/* Step through the directory one block at a time. */ |
306,8 → 344,10 |
strcmp(dp->d_name, "..") != 0) match = 1; |
} |
else { |
if (fs_strncmp(dp->d_name, string, NAME_MAX_EX) == 0) |
if (fs_strncmp(dp->d_name, string, NAME_MAX_EX) == 0) { |
match = 1; |
} |
|
} |
} |
|