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 10-09-2018, 04:50 PM   #1
AsmV
LQ Newbie
 
Registered: Oct 2018
Posts: 2

Rep: Reputation: Disabled
How to create a folder inside proc/pid


Hi ,

I am writing a character device with a Linux Kernel Module and the kernel version is : 4.14.74..
Basically, a user space process with a given tgid can interact with my device through ioctl.

I need to make a new directory inside /proc/pid (where pid is the tgid of the processes that have interacted with my device) so that I can create inside this new directory some files with some logs.

Is it possible to create a new directory inside /proc/pid without re-compiling the linux kernel?

In particular, I have tried to use :

Quote:
struct proc_dir_entry *proc_create(const char *name, umode_t mode,
struct proc_dir_entry *parent,
const struct file_operations *proc_fops)
but I am not able to get the struct proc_dir_entry * of the pid folder I want to write in because I am not able to include fs/proc/internal.h where PDE is defined.
Is it possible somehow to include PDE or replicate its behavior in my kernel module ?


Quote:
struct file *fp = filp_open("/proc/1",....);
struct proc_dir_entry *parent ;
parent = PDE(fp->f_dentry->d_inode);
Since
Any solution ?

Last edited by AsmV; 10-09-2018 at 05:17 PM. Reason: add further details
 
Old 10-10-2018, 12:29 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Why are you not able to include internal.h?
 
Old 10-10-2018, 03:05 PM   #3
AsmV
LQ Newbie
 
Registered: Oct 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
Why are you not able to include internal.h?
Because it is not accessible from the kernel module :
Quote:
fatal error: fs/proc/internal.h: No such file or directory
#include <fs/proc/internal.h>
Anyway even if I could use PDE, I think it does not work (return NULL) because pid entry are different.
I should modify on the fly the tgid_base_stuff[] defined in fs/proc/base.c to add a new pid entry

Last edited by AsmV; 10-10-2018 at 03:10 PM.
 
Old 10-10-2018, 08:22 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
/proc is not an actual directory/file system. From man proc:

Quote:
The proc filesystem is a pseudo-filesystem which provides an interface to kernel data structures. It is commonly mounted at /proc. Most of it is read-only, but some files allow kernel variables to be changed.
See the man page for more.
 
  


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] How does the kernel create /proc/$pid/maps dlevy022 Linux - Kernel 2 12-15-2015 11:12 AM
[SOLVED] Better way to create a folder for each month, with another folder inside of each anon091 Linux - Newbie 9 12-03-2012 10:38 AM
Read file in folder /proc/"pid"/fd/0 in ubuntu v11.10? newbie_member Linux - Newbie 4 07-19-2012 05:05 AM
pmap or /proc/<pid>smap or /proc/<pid>/status iQoder Linux - Newbie 1 07-16-2009 06:32 PM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM

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

All times are GMT -5. The time now is 10:41 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