Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to send a ioctl command on a symlink opened handle but I am getting errno = 9 (Bad file descriptor) and the call is no reaching my file system f_op->unlocked_ioctl.
Do the kernel restrict ioctl calls to symlink file ids? If so is there a workaround?
Sure. I am trying to get the access / modify time set to work with nfs ganesha. As of today nfs ganesha do not set the a/m time on a symlink (the call do not fails but it is not doing anything). nfs ganesha uses the name_to_handle_at/open_by_handle_at to get a handle for the file and when client send the setattr is passing this handle. In this call ganesha has the file id for the file, it doesn't have the name and it can't run utimensat - the only posix call to set the a/m time on a symlink. I thought that I can use a special ioctl to pass the a/m time using the file id of the symlink (as the backing of the exported nfs ganesha is a proprietary filesystem that I have the source code). The call works on a regular file but not on a symlink. It has to be some code in the OS that retuned errno = 9 when ioctl is called on a symlink file id. Is it possible to go around this?
The other alternative is to keep name and parent dir with the symlink in nfs ganesha but this is not working, in case the lru cache remove the entry and client retry with the file handle, server has no way to reconstruct name & parent dir from the handle.
symlink itself is not a real file, it is just a directory entry pointing to somewhere. On ext4 the a/m times are stored together with the inode of the file, but in this case there is no inode at all.
I can't use utimensat as this required dirfid and name and nfs ganesha do not keep them around, they just have the handle -> fid.
The symlink can be opened and it give back a user file id (if open with no follow), how is that generated? Some of posix commands like
fchownat(my_fd, "", user, group, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH) works with my_fd == file id of the symlink.
I think I see what's going on. In the ioctl command the kernel will try to get to the inode using the fid by querying the fdtable with:
__fdget - this uses __fget_light(fd, FMODE_PATH)
and in the search fd's with FMODE_PATH are not returned so the ioctl will not return the file object as symlink has to be open with O_PATH
The fchownat is using: __fget_light(fd, 0) and it will return any fd (so it also return a symlink with FMODE_PATH set).
The option would be top have an ioctl on our driver management port that would pass the symlink file id and have the code run the __fget_light(fd, 0) to get the file object.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.