Disable POSIX-required behavior wrt trailing slashes.
This commit is contained in:
parent
d232b2ef42
commit
c2bf536a55
@ -694,7 +694,6 @@ PUBLIC int do_mkdir()
|
|||||||
int r;
|
int r;
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
|
|
||||||
/*printf("VFS: mkdir() START:");*/
|
|
||||||
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
|
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);
|
bits = I_DIRECTORY | (m_in.mode & RWX_MODES & fp->fp_umask);
|
||||||
|
@ -21,10 +21,19 @@
|
|||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
#include "param.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,
|
FORWARD _PROTOTYPE( int lookup_rel, (struct vnode *start_node,
|
||||||
int flags, int use_realuid, node_details_t *node) );
|
int flags, int use_realuid, node_details_t *node) );
|
||||||
|
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* lookup_rel_vp *
|
* lookup_rel_vp *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
@ -122,15 +131,26 @@ struct vnode **vpp;
|
|||||||
* The lookup starts at start_node.
|
* The lookup starts at start_node.
|
||||||
*/
|
*/
|
||||||
int r;
|
int r;
|
||||||
|
size_t len;
|
||||||
char *cp;
|
char *cp;
|
||||||
char dir_entry[PATH_MAX+1];
|
char dir_entry[PATH_MAX+1];
|
||||||
|
|
||||||
if (strlen(user_fullpath) == 0)
|
len= strlen(user_fullpath);
|
||||||
|
if (len == 0)
|
||||||
{
|
{
|
||||||
/* Empty path, always fail */
|
/* Empty path, always fail */
|
||||||
return ENOENT;
|
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, '/');
|
cp= strrchr(user_fullpath, '/');
|
||||||
if (cp == NULL)
|
if (cp == NULL)
|
||||||
{
|
{
|
||||||
@ -143,6 +163,7 @@ struct vnode **vpp;
|
|||||||
else if (cp[1] == '\0')
|
else if (cp[1] == '\0')
|
||||||
{
|
{
|
||||||
/* Path ends in a slash. The directory entry is '.' */
|
/* Path ends in a slash. The directory entry is '.' */
|
||||||
|
strcpy(dir_entry, ".");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user