LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-16-2024, 01:22 AM   #1
harry.hycc
LQ Newbie
 
Registered: Feb 2024
Posts: 4

Rep: Reputation: 2
Question How to get full mountpoint path name by the sturct fc_context


I currently have a syscall hook named "fsconfig" within my own module because I need to perform some operations regarding remounting readonly mountpoints.

For example, if a user issues the command: mount /dev/sda /tmp/mytest -o remount,ro, I would like to obtain the string "/tmp/mytest" within the fsconfig hook.

Within fsconfig, I have referred to the kernel's approach, which allows obtaining an fs_context structure through an fd. What I aim to do is to obtain the mount point path through this structure (or any other method).

It seems that the fs_context provides all the information available at this step.

Currently, I have attempted:

Starting from fc_context->dentry, I have found some functions like dentry_path_raw, but the returned string is "/", which does not meet my requirements.

There is some information on the internet suggesting the use of d_path, but it requires a path structure containing dentry and vfsmount, which I cannot obtain within fsconfig. Therefore, this method seems impractical.

I have referenced the approach used in /proc/mounts, where they iterate through each mountpoint using the list within mnt_namespace. However, we cannot access the members of mnt_namespace and mount structures within the module (kernel declare them in fs/namespace), making this method unusable.

I would like to ask if there are any other methods (perhaps some kernel APIs I am not aware of) to meet my requirements. Thank you very much.

And i want my module to support kernel version 6.6
 
Old 02-17-2024, 09:08 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,863

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
duplicate of https://www.linuxquestions.org/quest...xt-4175733917/
 
  


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
How to get full mountpoint path name by the sturct fc_context harry.hycc Linux - Kernel 0 02-17-2024 09:44 AM
[SOLVED] Installing an extra version of CMake - can run from full path but not from $PATH mattachu Linux - Software 1 05-23-2014 03:58 PM
how do i get string path name from a struct path? conlonloi Programming 2 11-29-2011 03:05 PM
Shell: tr can only be used when given full path (despite being in $PATH) chochem Programming 2 06-27-2008 08:37 AM
how to get my mountpoint back after partitioning? xpucto Linux - Newbie 5 07-25-2007 04:10 PM

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

All times are GMT -5. The time now is 05:39 PM.

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