(lstat_file): handle case where file lives in `/'

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9481 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2001-01-18 23:03:02 +00:00
parent 8abcfe8b12
commit 6cbdce797a

View File

@@ -342,10 +342,11 @@ lstat_file (const char *file, struct stat *sb)
#ifdef KRB4
if (k_hasafs()
&& strcmp(file, ".")
&& strcmp(file, ".."))
&& strcmp(file, "..")
&& strcmp(file, "/"))
{
struct ViceIoctl a_params;
char *last;
char *dir, *last;
char *path_bkp;
static ino_t ino_counter = 0, ino_last = 0;
int ret;
@@ -365,16 +366,28 @@ lstat_file (const char *file, struct stat *sb)
last = strrchr (path_bkp, '/');
if (last != NULL) {
*last = '\0';
a_params.in = last + 1;
} else
a_params.in = (char *)file;
if(last[1] == '\0')
/* if path ended in /, replace with `.' */
a_params.in = ".";
else
a_params.in = last + 1;
while(last > path_bkp && *--last == '/');
if(last != path_bkp) {
*++last = '\0';
dir = path_bkp;
} else
/* we got to the start, so this must be the root dir */
dir = "/";
} else {
/* file is relative to cdir */
dir = ".";
a_params.in = path_bkp;
}
a_params.in_size = strlen (a_params.in) + 1;
a_params.out_size = maxsize;
ret = k_pioctl (last ? path_bkp : "." ,
VIOC_AFS_STAT_MT_PT, &a_params, 0);
ret = k_pioctl (dir, VIOC_AFS_STAT_MT_PT, &a_params, 0);
free (a_params.out);
if (ret < 0) {
free (path_bkp);
@@ -391,7 +404,7 @@ lstat_file (const char *file, struct stat *sb)
* use . as a prototype
*/
ret = lstat (path_bkp, sb);
ret = lstat (dir, sb);
free (path_bkp);
if (ret < 0)
return ret;