Disable POSIX-required behavior wrt trailing slashes.

This commit is contained in:
Philip Homburg 2007-08-08 11:40:47 +00:00
parent d232b2ef42
commit c2bf536a55
2 changed files with 23 additions and 3 deletions

View File

@ -694,7 +694,6 @@ PUBLIC int do_mkdir()
int r;
struct vnode *vp;
/*printf("VFS: mkdir() START:");*/
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
bits = I_DIRECTORY | (m_in.mode & RWX_MODES & fp->fp_umask);

View File

@ -21,10 +21,19 @@
#include "vnode.h"
#include "param.h"
/* Set to following define to 1 if you really want to use the POSIX definition
* (IEEE Std 1003.1, 2004) of pathname resolution. POSIX requires pathnames
* with a traling slash (and that do not entirely consist of slash characters)
* to be treated as if a single dot is appended. This means that for example
* mkdir("dir/", ...) and rmdir("dir/") will fail because the call tries to
* create or remove the directory '.'. Historically, Unix systems just ignore
* trailing slashes.
*/
#define DO_POSIX_PATHNAME_RES 0
FORWARD _PROTOTYPE( int lookup_rel, (struct vnode *start_node,
int flags, int use_realuid, node_details_t *node) );
/*===========================================================================*
* lookup_rel_vp *
*===========================================================================*/
@ -122,15 +131,26 @@ struct vnode **vpp;
* The lookup starts at start_node.
*/
int r;
size_t len;
char *cp;
char dir_entry[PATH_MAX+1];
if (strlen(user_fullpath) == 0)
len= strlen(user_fullpath);
if (len == 0)
{
/* Empty path, always fail */
return ENOENT;
}
#if !DO_POSIX_PATHNAME_RES
/* Remove trailing slashes */
while (len > 1 && user_fullpath[len-1] == '/')
{
len--;
user_fullpath[len]= '\0';
}
#endif
cp= strrchr(user_fullpath, '/');
if (cp == NULL)
{
@ -143,6 +163,7 @@ struct vnode **vpp;
else if (cp[1] == '\0')
{
/* Path ends in a slash. The directory entry is '.' */
strcpy(dir_entry, ".");
}
else
{