From c043ef95a3fcea2e50b8650dda139cc023c56773 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Mon, 3 Apr 2017 21:11:20 -0400 Subject: [PATCH] make fs::attr return ENOTSUP on EINVAL #381 --- src/fs_attr_linux.icpp | 16 ++++++++++++++-- src/fs_attr_unsupported.icpp | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/fs_attr_linux.icpp b/src/fs_attr_linux.icpp index 66722fb3..6cac839f 100644 --- a/src/fs_attr_linux.icpp +++ b/src/fs_attr_linux.icpp @@ -35,7 +35,13 @@ namespace fs get_fs_ioc_flags(const int fd, int &flags) { - return fs::ioctl(fd,FS_IOC_GETFLAGS,(void*)&flags); + int rv; + + rv = fs::ioctl(fd,FS_IOC_GETFLAGS,(void*)&flags); + if((rv == -1) && (errno == EINVAL)) + errno = ENOTSUP; + + return rv; } static @@ -68,7 +74,13 @@ namespace fs set_fs_ioc_flags(const int fd, const int flags) { - return fs::ioctl(fd,FS_IOC_SETFLAGS,(void*)&flags); + int rv; + + rv = fs::ioctl(fd,FS_IOC_SETFLAGS,(void*)&flags); + if((rv == -1) && (errno == EINVAL)) + errno = ENOTSUP; + + return rv; } static diff --git a/src/fs_attr_unsupported.icpp b/src/fs_attr_unsupported.icpp index 8be00461..63ca83f0 100644 --- a/src/fs_attr_unsupported.icpp +++ b/src/fs_attr_unsupported.icpp @@ -26,14 +26,14 @@ namespace fs copy(const int fdin, const int fdout) { - return ENOTSUP; + return (errno=ENOTSUP,-1); } int copy(const std::string &from, const std::string &to) { - return ENOTSUP; + return (errno=ENOTSUP,-1); } } }