On Mon, Feb 20, 2017 at 03:41:00PM +0100, Greg Kurz wrote: > + dirfd = local_opendir_nofollow(ctx, dirpath); > + if (dirfd) { > + goto out; > } > > - buffer = rpath(ctx, path); > - err = remove(buffer); > - g_free(buffer); > + if (fstatat(dirfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) { > + goto err_out; > + } > + > + if (S_ISDIR(stbuf.st_mode)) { > + flags |= AT_REMOVEDIR; > + } > + > + err = local_unlinkat_common(ctx, dirfd, name, flags);
The alternative is optimistically skip fstat but then do: if (err == EISDIR) { err = local_unlinkat_common(ctx, dirfd, name, flags | AT_REMOVEDIR); } It might be faster. Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
signature.asc
Description: PGP signature