Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP

Loading…

exporting through symlinks/stat vs lstat in diod_walk() #17

Merged
merged 1 commit into from

2 participants

@pipcet

Hi,
this (single-character) change fixes a problem for me when exporting through a symlink to a directory on a different file system. If "link" is such a symlink, lstat("link") and lstat("link/file") will have different device ids; that makes diod_walk call _statmnt("link/file"), which tries to stat("link/file/.."), which fails with ENOTDIR:

[pid 27405] lstat("/srv/nfs/git/initramfs-tools_0.120_amd64.changes", {st_mode=S_IFREG|0644, st_size=1713, ...}) = 0
[pid 27405] lstat("/srv/nfs/git", {st_mode=S_IFLNK|0777, st_size=13, ...}) = 0
[pid 27405] stat("/srv/nfs/git/initramfs-tools_0.120_amd64.changes", {st_mode=S_IFREG|0644, st_size=1713, ...}) = 0
[pid 27405] stat("/srv/nfs/git/initramfs-tools_0.120_amd64.changes/..", 0x7f13c4fe8a40) = -1 ENOTDIR (Not a directory)

I believe the correct thing to do is to stat(f->path), which follows the symlink and returns the same device as lstat(npath) if the latter is a file residing in f.

@pipcet pipcet use stat() rather than lstat() to decide whether a directory entry is a
mount point.

if /link is a link to a directory on a different file system,
lstat(/link) and lstat(/link/file) have different .st_devs, even though
/link/file is an ordinary file in a symlinked directory; stat(/link) and
lstat(/link/file) have the same .st_devs, so I believe we should be
testing that condition instead.
299e16b
@garlick garlick merged commit 171ac34 into chaos:master
@pipcet pipcet deleted the pipcet:lstat-stat branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2015
  1. @pipcet

    use stat() rather than lstat() to decide whether a directory entry is a

    pipcet authored
    mount point.
    
    if /link is a link to a directory on a different file system,
    lstat(/link) and lstat(/link/file) have different .st_devs, even though
    /link/file is an ordinary file in a symlinked directory; stat(/link) and
    lstat(/link/file) have the same .st_devs, so I believe we should be
    testing that condition instead.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  diod/ops.c
View
2  diod/ops.c
@@ -426,7 +426,7 @@ diod_walk (Npfid *fid, Npstr* wname, Npqid *wqid)
np_uerror (errno);
goto error_quiet;
}
- if (lstat (path_s (f->path), &sb2) < 0) {
+ if (stat (path_s (f->path), &sb2) < 0) {
np_uerror (errno);
goto error;
}
Something went wrong with that request. Please try again.