Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions backend/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1751,8 +1751,19 @@ fs_remove(void *softc, struct l9p_fid *fid)
return (error);

if (unlinkat(file->ff_dirfd, file->ff_name,
S_ISDIR(cst.st_mode) ? AT_REMOVEDIR : 0) != 0)
S_ISDIR(cst.st_mode) ? AT_REMOVEDIR : 0) != 0) {
error = errno;
/*
* POSIX allows unlinkat() with AT_REMOVEDIR on a non-empty
* directory to return either ENOTEMPTY or EEXIST. illumos
* and Solaris return EEXIST, apparently because System V did
* not have ENOTEMPTY.
* Since Tunlinkat is part of 9P2000.L, which uses Linux
* errnos, translate that here.
*/
if (error == EEXIST && S_ISDIR(cst.st_mode))
error = ENOTEMPTY;
}

return (error);
}
Expand Down Expand Up @@ -2931,8 +2942,19 @@ fs_unlinkat(void *softc, struct l9p_request *req)
return (error);

if (req->lr_req.tunlinkat.flags & L9PL_AT_REMOVEDIR) {
if (unlinkat(dirff->ff_dirfd, newname, AT_REMOVEDIR) != 0)
if (unlinkat(dirff->ff_dirfd, newname, AT_REMOVEDIR) != 0) {
error = errno;
/*
* POSIX allows unlinkat() with AT_REMOVEDIR on a
* non-empty directory to return either ENOTEMPTY or
* EEXIST. illumos and Solaris return EEXIST, apparently
* because System V did not have ENOTEMPTY. Since
* Tunlinkat is part of 9P2000.L, which uses Linux
* errnos, translate that here.
*/
if (error == EEXIST)
error = ENOTEMPTY;
}
} else {
if (unlinkat(dirff->ff_dirfd, newname, 0) != 0)
error = errno;
Expand Down
6 changes: 3 additions & 3 deletions request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1404,12 +1404,12 @@ l9p_dispatch_trenameat(struct l9p_request *req)
int error;

error = fid_lookup(conn, req->lr_req.hdr.fid, ENOENT,
F_REQUIRE_DIR | F_FORBID_OPEN, &req->lr_fid);
F_REQUIRE_DIR, &req->lr_fid);
if (error)
return (error);

error = fid_lookup(conn, req->lr_req.trenameat.newdirfid, ENOENT,
F_REQUIRE_DIR | F_FORBID_OPEN, &req->lr_fid2);
F_REQUIRE_DIR, &req->lr_fid2);
if (error)
return (error);

Expand All @@ -1428,7 +1428,7 @@ l9p_dispatch_tunlinkat(struct l9p_request *req)
int error;

error = fid_lookup(conn, req->lr_req.hdr.fid, ENOENT,
F_REQUIRE_DIR | F_FORBID_OPEN, &req->lr_fid);
F_REQUIRE_DIR, &req->lr_fid);
if (error)
return (error);

Expand Down