: Return better error code from vfs_unlink if operation is not defined.
PATCH 1/1 : Return better error code from vfs_unlink if operation is not defined.
Hi,
If the unlink function is not defined by filesystem, then I think it is better to return operation not supported rather than saying permission denied, which can come from lot other places and keep user guessing what went wrong. I came across this while testing one of my small modules.
--- fs/namei.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/namei.c +1 -1
@@ -2208,7 +2208,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)return error;if (!dir->i_op->unlink) -return -EPERM ; +return -EOPNOTSUPP ;DQUOT_INIT (dir);
Signature · 4 lines
1.5.4.3 Thanks - Manish
Quoted 5 lines · Manish Katiyar
If the unlink function is not defined by filesystem, then I think it is better to return operation not supported rather than saying permission denied, which can come from lot other places and keep user guessing what went wrong. I came across this while testing one of my small modules.
-EOPNOTSUPP is not a valid return value from unlink(). It's also documented in the manpage:
EPERM (Linux only)
The file system does not allow unlinking of files.
In general, you should never use -EOPNOTSUPP. It's only for use by networking STREAMS.
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 8 lines · Matthew Wilcox
Quoted 5 lines · Manish Katiyar
If the unlink function is not defined by filesystem, then I think it is better to return operation not supported rather than saying permission denied, which can come from lot other places and keep user guessing what went wrong. I came across this while testing one of my small modules.
-EOPNOTSUPPis not a valid return value fromunlink().
Why ? I mean are there any issues if we return this ? Does it break anything ?
Quoted 5 lines
It's also
documented in the manpage:EPERM (Linux only)
The file system does not allow unlinking of files.
English is not my first language, but still I think the above statement only means that filesystem didn't allow to unlink (whether it was actually due to permission issues or the function was not implemented is not known).
Quoted 3 lines
In general, you should never use
-EOPNOTSUPP. It's only for use by networking STREAMS.
Hmm.... OK, but I would like to know the reasons behind it
Thanks Matthew for your comments.
Thanks -
Manish
Quoted 7 lines
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."