Skip to content

Commit

Permalink
hw/9pfs: make get_st_gen() return ENOTTY error on special files
Browse files Browse the repository at this point in the history
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.shutemov@linux.intel.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  • Loading branch information
kiryl authored and kvaneesh committed Feb 2, 2014
1 parent b931766 commit 1a9978a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion hw/9pfs/virtio-9p-handle.c
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion hw/9pfs/virtio-9p-local.c
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion hw/9pfs/virtio-9p-proxy.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 1a9978a

Please sign in to comment.