From: Ben Gras Date: Wed, 28 Feb 2007 13:13:39 +0000 (+0000) Subject: Minor change to path lookup that fixes the bug that creating a file X-Git-Tag: v3.1.3~53 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch02.html?a=commitdiff_plain;h=52b71b2396da7492e99c90a2ad873634fca0d326;p=minix.git Minor change to path lookup that fixes the bug that creating a file as a first component of an absolute path failed (e.g. 'touch /file'), due to leading slashes not being skipped in the processed path counter in that case, causing create to fail. --- diff --git a/servers/mfs/path.c b/servers/mfs/path.c index 9158f8def..cc583608a 100644 --- a/servers/mfs/path.c +++ b/servers/mfs/path.c @@ -196,9 +196,14 @@ printf("%s, %d\n", __FILE__, __LINE__); /* Scan the path component by component. */ while (TRUE) { - /* Extract one component. */ + int slashes = 0; + /* Extract one component. Skip slashes first. */ + while (path[slashes] == '/') { + slashes++; + path_processed++; + } fs_m_out.RES_OFFSET = path_processed; /* For ENOENT */ - if ( (new_name = get_name(path, string)) == (char*) 0) { + if ( (new_name = get_name(path+slashes, string)) == (char*) 0) { put_inode(rip); /* bad path in user space */ printf("%s, %d\n", __FILE__, __LINE__); return(NIL_INODE); @@ -487,11 +492,8 @@ char string[NAME_MAX]; /* component extracted from 'old_name' */ np = string; /* 'np' points to current position */ rnp = old_name; /* 'rnp' points to unparsed string */ - while ( (c = *rnp) == '/') { - rnp++; /* skip leading slashes */ - path_processed++; /* count characters */ - } + c = *rnp; /* Copy the unparsed path, 'old_name', to the array, 'string'. */ while ( rnp < &old_name[PATH_MAX] && c != '/' && c != '\0') { if (np < &string[NAME_MAX]) *np++ = c;