"Kirill A. Shutemov" <kirill.shute...@linux.intel.com> writes:
> Currently we silently ignore getversion requests for anything except > file or directory. Let's instead return ENOTTY error to indicate that > getversion is not supported. It makes implementation consistent on > all not-supported cases. > > Signed-off-by: Kirill A. Shutemov <kirill.shute...@linux.intel.com> Reviewed-by: Aneesh Kumar K.V <aneesh.ku...@linux.vnet.ibm.com> > --- > hw/9pfs/virtio-9p-handle.c | 3 ++- > hw/9pfs/virtio-9p-local.c | 3 ++- > hw/9pfs/virtio-9p-proxy.c | 3 ++- > 3 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c > index ed8c126e1d6c..17002a3d2867 100644 > --- a/hw/9pfs/virtio-9p-handle.c > +++ b/hw/9pfs/virtio-9p-handle.c > @@ -591,7 +591,8 @@ static int handle_ioc_getversion(FsContext *ctx, V9fsPath > *path, > * We can get fd for regular files and directories only > */ > if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { > - return 0; > + errno = ENOTTY; > + return -1; > } > err = handle_open(ctx, path, O_RDONLY, &fid_open); > if (err < 0) { > diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c > index 9be8854e9148..df0dbffa7ac4 100644 > --- a/hw/9pfs/virtio-9p-local.c > +++ b/hw/9pfs/virtio-9p-local.c > @@ -1077,7 +1077,8 @@ static int local_ioc_getversion(FsContext *ctx, > V9fsPath *path, > * We can get fd for regular files and directories only > */ > if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { > - return 0; > + errno = ENOTTY; > + return -1; > } > err = local_open(ctx, path, O_RDONLY, &fid_open); > if (err < 0) { > diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c > index 5f44bb758b35..b57966d9d883 100644 > --- a/hw/9pfs/virtio-9p-proxy.c > +++ b/hw/9pfs/virtio-9p-proxy.c > @@ -1086,7 +1086,8 @@ static int proxy_ioc_getversion(FsContext *fs_ctx, > V9fsPath *path, > * we can get fd for regular files and directories only > */ > if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { > - return 0; > + errno = ENOTTY; > + return -1; > } > err = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, "s", path); > if (err < 0) { > -- > 1.8.5.2