Skip to content

Commit

Permalink
fs-posix: Strip trailing "/" from filenames
Browse files Browse the repository at this point in the history
This is mainly because "doveadm fs delete -R" adds it to indicate to the
fs-driver that the whole directory is wanted to be deleted. This change
fixes fs-posix to work with NFS, where otherwise unlink("symlink-to-dir/")
fails with ENOTDIR. Without NFS the same call succeeds.
  • Loading branch information
sirainen authored and villesavolainen committed May 18, 2018
1 parent 6e467d1 commit 7e5c160
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib-fs/fs-posix.c
Expand Up @@ -320,6 +320,13 @@ fs_posix_file_init(struct fs *_fs, const char *path,
struct posix_fs *fs = (struct posix_fs *)_fs;
struct posix_fs_file *file;
guid_128_t guid;
size_t path_len = strlen(path);

if (path_len > 0 && path[path_len-1] == '/') {
/* deleting "path/" (used e.g. by doveadm fs delete) - strip
out the trailing "/" since it doesn't work well with NFS. */
path = t_strndup(path, path_len-1);
}

file = i_new(struct posix_fs_file, 1);
file->file.fs = _fs;
Expand Down

0 comments on commit 7e5c160

Please sign in to comment.