qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 13/29] 9pfs: local: remove: don't follow symlink


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 13/29] 9pfs: local: remove: don't follow symlinks
Date: Thu, 23 Feb 2017 14:23:15 +0000
User-agent: Mutt/1.7.1 (2016-10-04)

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 <address@hidden>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]