LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-24-2023, 03:19 PM   #1
rvines
LQ Newbie
 
Registered: Aug 2023
Posts: 4

Rep: Reputation: 0
ioctl command on a symlink file id


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?
 
Old 08-25-2023, 01:43 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,042

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
would be nice to show what did you really try and explain what did you try to achieve at all.
 
Old 08-25-2023, 10:48 AM   #3
rvines
LQ Newbie
 
Registered: Aug 2023
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
Old 08-25-2023, 12:01 PM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,042

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
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.
 
Old 08-25-2023, 12:13 PM   #5
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,160

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
You don't say what ioctl you're using, but one way to update times on a symlink is with the utimensat call with AT_SYMLINK_NOFOLLOW flag.

Last edited by smallpond; 08-25-2023 at 12:16 PM. Reason: fix call name
 
Old 08-25-2023, 01:21 PM   #6
rvines
LQ Newbie
 
Registered: Aug 2023
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
Old 08-25-2023, 03:33 PM   #7
rvines
LQ Newbie
 
Registered: Aug 2023
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] symlink to symlink confusion, Reprovo Linux - Newbie 2 11-18-2014 02:17 PM
Getting File Descriptor for a USB device to pass to ioctl command linuxsy Linux - Kernel 0 08-07-2012 04:45 AM
Question How to get stat() of symlink and not of target of symlink ? ronbarak Programming 3 11-08-2010 12:14 PM
How to pass IOCTL arguments from usespace ioctl call devkpict Linux - Kernel 1 12-07-2007 06:45 PM
change the original file when i change the symlink to that file sailu_mvn Linux - Desktop 2 04-19-2007 04:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration