summaryrefslogtreecommitdiff
path: root/libtreefs
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-02-28 01:52:11 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-02-28 01:56:11 +0100
commit6e8e837864d4e24c2fdb4d90e8eb262ded78c3a8 (patch)
tree47022b7fe9e8344ad1c1765e15122067072f0fba /libtreefs
parenteeeb27ee14064dff84c833b4359d43d9869a9342 (diff)
Fix mustbedir mechanism for symlinks
* libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): When following a symlink, if mustbedir is true, always append a slash to the symlink target, not only when the target is absolute. Reset mustbedir to 0 before continuing the lookup loop. * libnetfs/dir-lookup.c (netfs_S_dir_lookup): When following a symlink, if mustbedir is true, append a slash to the symlink target. Reset mustbedir to 0 before continuing the lookup loop. * libtreefs/dir-lookup.c (_treefs_s_dir_lookup): Likewise.
Diffstat (limited to 'libtreefs')
-rw-r--r--libtreefs/dir-lookup.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libtreefs/dir-lookup.c b/libtreefs/dir-lookup.c
index 8665059c..80b55388 100644
--- a/libtreefs/dir-lookup.c
+++ b/libtreefs/dir-lookup.c
@@ -229,7 +229,7 @@ _treefs_s_dir_lookup (struct treefs_handle *h,
/* Symlink contents + extra path won't fit in our buffer, so
reallocate it and try again. */
{
- path_buf_len = sym_len + nextname_len + 1;
+ path_buf_len = sym_len + nextname_len + 1 + 1;
path_buf = alloca (path_buf_len);
err = treefs_node_get_symlink (node, path_buf, &sym_len);
}
@@ -241,7 +241,13 @@ _treefs_s_dir_lookup (struct treefs_handle *h,
path_buf[sym_len] = '/';
bcopy (nextname, path_buf + sym_len + 1, nextname_len - 1);
}
- path_buf[nextname_len + sym_len] = '\0';
+ if (mustbedir)
+ {
+ path_buf[nextnamelen + sym_len] = '/';
+ path_buf[nextnamelen + sym_len + 1] = '\0';
+ }
+ else
+ path_buf[nextname_len + sym_len] = '\0';
if (path_buf[0] == '/')
{
@@ -253,6 +259,7 @@ _treefs_s_dir_lookup (struct treefs_handle *h,
}
path = path_buf;
+ mustbedir = 0;
if (lastcomp)
{
lastcomp = 0;