qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH -V3 6/8] hw/9pfs: Add directory reclaim support


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH -V3 6/8] hw/9pfs: Add directory reclaim support
Date: Sun, 13 Mar 2011 16:42:56 +0000

On Sat, Mar 5, 2011 at 5:52 PM, Aneesh Kumar K.V
<address@hidden> wrote:
> Signed-off-by: Aneesh Kumar K.V <address@hidden>
> ---
>  hw/9pfs/virtio-9p.c |   21 +++++++++++++++++++--
>  1 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
> index 1fa7256..293a562 100644
> --- a/hw/9pfs/virtio-9p.c
> +++ b/hw/9pfs/virtio-9p.c
> @@ -142,7 +142,12 @@ static int v9fs_do_open(V9fsState *s, V9fsString *path, 
> int flags)
>
>  static DIR *v9fs_do_opendir(V9fsState *s, V9fsString *path)
>  {
> -    return s->ops->opendir(&s->ctx, path->data);
> +    DIR *dir;
> +    dir = s->ops->opendir(&s->ctx, path->data);
> +    if (dirfd(dir) > P9_FD_RECLAIM_THRES) {
> +        v9fs_reclaim_fd(s);
> +    }

dirfd(NULL) will crash so we need to check !dir first:

$ cat dirfd.c
#include <stdio.h>

int main(int argc, char **argv)
{
        printf("%d\n", dirfd(NULL));
        return 0;
}

$ gcc -o dirfd dirfd.c
$ ./dirfd
Segmentation fault

Stefan



reply via email to

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