summaryrefslogtreecommitdiff
path: root/libdiskfs/dir-lookup.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-08-02 20:41:23 +0000
committerRoland McGrath <roland@gnu.org>2001-08-02 20:41:23 +0000
commitd8b4a105fe549d981ccd8974150968300e61d8d8 (patch)
treee5f729ab4966780c3d38104fe09f92dfef9f13dd /libdiskfs/dir-lookup.c
parent71db48bc2585cc645d7740508822fb25e374f41c (diff)
2001-06-19 Roland McGrath <roland@frob.com>
* dir-lookup.c (diskfs_S_dir_lookup): Handle symlinks to "".
Diffstat (limited to 'libdiskfs/dir-lookup.c')
-rw-r--r--libdiskfs/dir-lookup.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 3d749dd5..402371d4 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -333,30 +333,39 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (diskfs_read_symlink_hook)
error = (*diskfs_read_symlink_hook)(np, pathbuf);
if (!diskfs_read_symlink_hook || error == EINVAL)
- error = diskfs_node_rdwr (np, pathbuf,
- 0, np->dn_stat.st_size, 0,
- dircred, &amt);
+ {
+ error = diskfs_node_rdwr (np, pathbuf,
+ 0, np->dn_stat.st_size, 0,
+ dircred, &amt);
+ if (!error)
+ assert (amt == np->dn_stat.st_size);
+ }
if (error)
goto out;
- if (nextname)
+ if (np->dn_stat.st_size == 0) /* symlink to "" */
+ path = nextname;
+ else
{
- pathbuf[np->dn_stat.st_size] = '/';
- bcopy (nextname, pathbuf + np->dn_stat.st_size + 1,
- nextnamelen - 1);
- }
- pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
+ if (nextname)
+ {
+ pathbuf[np->dn_stat.st_size] = '/';
+ bcopy (nextname, pathbuf + np->dn_stat.st_size + 1,
+ nextnamelen - 1);
+ }
+ pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
- if (pathbuf[0] == '/')
- {
- /* Punt to the caller. */
- *retry = FS_RETRY_MAGICAL;
- *returned_port = MACH_PORT_NULL;
- strcpy (retryname, pathbuf);
- goto out;
+ if (pathbuf[0] == '/')
+ {
+ /* Punt to the caller. */
+ *retry = FS_RETRY_MAGICAL;
+ *returned_port = MACH_PORT_NULL;
+ strcpy (retryname, pathbuf);
+ goto out;
+ }
+ path = pathbuf;
}
- path = pathbuf;
if (lastcomp)
{
lastcomp = 0;
@@ -364,8 +373,16 @@ diskfs_S_dir_lookup (struct protid *dircred,
creation, so clear the flag here. */
create = 0;
}
+
diskfs_nput (np);
np = 0;
+
+ if (path == 0) /* symlink to "" was the last component */
+ {
+ np = dnp;
+ dnp = 0;
+ break;
+ }
}
else
{