Can user space programs provide/implement sysfs or procfs files to pass data to and from a program?
Kernel space device drivers usually implement directories and file that show through /sys
or /proc
. Can the long running user space programs do this as well?
I have a daemon or long running program that needs to be able to be queried for some data and have some data set by external programs while it runs.
I could do a full blown sockets interface, but that's a lot of overhead for the program and the external requestors.
As the linux kernel developers found, using the "everything is a file" model was useful for tweaking kernel setting. I'd like to do the same.
Some may think the /sys
directory is the sacred space of the kernel, but I don't see an important line between what is what is the "system" and some other services/servers/applications.
Using FUSE...
I've decided to use FUSE, the 'File system in USErspace' package libfuse3.so.
(After writing a wrapper for it...) I can define an array of structs, one per access variable/file:
struct fileObj files = {
{"mode", mode, getFunc, putFunc},
{"numbProcs", numbProcs, getFunc, putFunc},
{"svrHostPort", hostPort, getFunc, putFunc},
{"somethingWO", jakeBuf, NULL, putFunc}, // Write only file (why?)
{"timestamp", NULL, getTimestampFunc, NULL}, // Returns timestamp, R/O
{0}
};
The mountpoint for the FUSE filesystem is '/ssm/fuse'... The 'ls -l' shows that each entry in the 'files' array shows up as a file, some R/O, some R/W, one W/O. The 'getTimestampFunc in the 'get' function position shows that a special function can be associated with a file to perform calculate repsonses.
ribo@box:~/c$ ls -l /ssm/fuse
total 0
-rw-r--r-- 1 ribo ribo 10 Dec 28 17:17 mode
-rw-r--r-- 1 ribo ribo 1 Dec 28 17:17 numbProcs
--w------- 1 ribo ribo 3 Dec 28 17:17 somethingWO
-rw-r--r-- 1 ribo ribo 5 Dec 28 17:17 svrHostPort
-r--r--r-- 1 ribo ribo 32 Dec 28 17:17 timestamp
ribo@box:~/c$ cat /ssm/fuse/timestamp
18/12/28 17:17:27ribo@box:~/c$cat /ssm/fuse/mode
hyperSpeedribo@box:~/c$ echo slow >/ssm/fuse/mode
ribo@box:~/c$ cat /ssm/fuse/mode
slow
The 'echo >' shows passing a value into the program. So its easy for me to peek and poke various parameters of the program as it runs.
fuse sysfs procfs
add a comment |
Kernel space device drivers usually implement directories and file that show through /sys
or /proc
. Can the long running user space programs do this as well?
I have a daemon or long running program that needs to be able to be queried for some data and have some data set by external programs while it runs.
I could do a full blown sockets interface, but that's a lot of overhead for the program and the external requestors.
As the linux kernel developers found, using the "everything is a file" model was useful for tweaking kernel setting. I'd like to do the same.
Some may think the /sys
directory is the sacred space of the kernel, but I don't see an important line between what is what is the "system" and some other services/servers/applications.
Using FUSE...
I've decided to use FUSE, the 'File system in USErspace' package libfuse3.so.
(After writing a wrapper for it...) I can define an array of structs, one per access variable/file:
struct fileObj files = {
{"mode", mode, getFunc, putFunc},
{"numbProcs", numbProcs, getFunc, putFunc},
{"svrHostPort", hostPort, getFunc, putFunc},
{"somethingWO", jakeBuf, NULL, putFunc}, // Write only file (why?)
{"timestamp", NULL, getTimestampFunc, NULL}, // Returns timestamp, R/O
{0}
};
The mountpoint for the FUSE filesystem is '/ssm/fuse'... The 'ls -l' shows that each entry in the 'files' array shows up as a file, some R/O, some R/W, one W/O. The 'getTimestampFunc in the 'get' function position shows that a special function can be associated with a file to perform calculate repsonses.
ribo@box:~/c$ ls -l /ssm/fuse
total 0
-rw-r--r-- 1 ribo ribo 10 Dec 28 17:17 mode
-rw-r--r-- 1 ribo ribo 1 Dec 28 17:17 numbProcs
--w------- 1 ribo ribo 3 Dec 28 17:17 somethingWO
-rw-r--r-- 1 ribo ribo 5 Dec 28 17:17 svrHostPort
-r--r--r-- 1 ribo ribo 32 Dec 28 17:17 timestamp
ribo@box:~/c$ cat /ssm/fuse/timestamp
18/12/28 17:17:27ribo@box:~/c$cat /ssm/fuse/mode
hyperSpeedribo@box:~/c$ echo slow >/ssm/fuse/mode
ribo@box:~/c$ cat /ssm/fuse/mode
slow
The 'echo >' shows passing a value into the program. So its easy for me to peek and poke various parameters of the program as it runs.
fuse sysfs procfs
1
I don't understand the question. Yes, you can mount a fuse filesystem under /proc or /sys, or even in place of them (see: lxcfs). The question is why you would want to do this when you can just as easily mount a filesystem in /run/myapp or similar?
– CameronNemo
Dec 29 '18 at 5:00
@CameronNemo -- Original purpose of question was to find a means to query/poke parameters in a long running program. My guess was adding a directory or a couple files to /proc or /sys would be easy and effective -- rather than using pipes, socket etc. I ended up creating my own fuse mount to do it. I hoped adding on to /sys or /proc would be simpler.
– Ribo
Dec 30 '18 at 16:26
add a comment |
Kernel space device drivers usually implement directories and file that show through /sys
or /proc
. Can the long running user space programs do this as well?
I have a daemon or long running program that needs to be able to be queried for some data and have some data set by external programs while it runs.
I could do a full blown sockets interface, but that's a lot of overhead for the program and the external requestors.
As the linux kernel developers found, using the "everything is a file" model was useful for tweaking kernel setting. I'd like to do the same.
Some may think the /sys
directory is the sacred space of the kernel, but I don't see an important line between what is what is the "system" and some other services/servers/applications.
Using FUSE...
I've decided to use FUSE, the 'File system in USErspace' package libfuse3.so.
(After writing a wrapper for it...) I can define an array of structs, one per access variable/file:
struct fileObj files = {
{"mode", mode, getFunc, putFunc},
{"numbProcs", numbProcs, getFunc, putFunc},
{"svrHostPort", hostPort, getFunc, putFunc},
{"somethingWO", jakeBuf, NULL, putFunc}, // Write only file (why?)
{"timestamp", NULL, getTimestampFunc, NULL}, // Returns timestamp, R/O
{0}
};
The mountpoint for the FUSE filesystem is '/ssm/fuse'... The 'ls -l' shows that each entry in the 'files' array shows up as a file, some R/O, some R/W, one W/O. The 'getTimestampFunc in the 'get' function position shows that a special function can be associated with a file to perform calculate repsonses.
ribo@box:~/c$ ls -l /ssm/fuse
total 0
-rw-r--r-- 1 ribo ribo 10 Dec 28 17:17 mode
-rw-r--r-- 1 ribo ribo 1 Dec 28 17:17 numbProcs
--w------- 1 ribo ribo 3 Dec 28 17:17 somethingWO
-rw-r--r-- 1 ribo ribo 5 Dec 28 17:17 svrHostPort
-r--r--r-- 1 ribo ribo 32 Dec 28 17:17 timestamp
ribo@box:~/c$ cat /ssm/fuse/timestamp
18/12/28 17:17:27ribo@box:~/c$cat /ssm/fuse/mode
hyperSpeedribo@box:~/c$ echo slow >/ssm/fuse/mode
ribo@box:~/c$ cat /ssm/fuse/mode
slow
The 'echo >' shows passing a value into the program. So its easy for me to peek and poke various parameters of the program as it runs.
fuse sysfs procfs
Kernel space device drivers usually implement directories and file that show through /sys
or /proc
. Can the long running user space programs do this as well?
I have a daemon or long running program that needs to be able to be queried for some data and have some data set by external programs while it runs.
I could do a full blown sockets interface, but that's a lot of overhead for the program and the external requestors.
As the linux kernel developers found, using the "everything is a file" model was useful for tweaking kernel setting. I'd like to do the same.
Some may think the /sys
directory is the sacred space of the kernel, but I don't see an important line between what is what is the "system" and some other services/servers/applications.
Using FUSE...
I've decided to use FUSE, the 'File system in USErspace' package libfuse3.so.
(After writing a wrapper for it...) I can define an array of structs, one per access variable/file:
struct fileObj files = {
{"mode", mode, getFunc, putFunc},
{"numbProcs", numbProcs, getFunc, putFunc},
{"svrHostPort", hostPort, getFunc, putFunc},
{"somethingWO", jakeBuf, NULL, putFunc}, // Write only file (why?)
{"timestamp", NULL, getTimestampFunc, NULL}, // Returns timestamp, R/O
{0}
};
The mountpoint for the FUSE filesystem is '/ssm/fuse'... The 'ls -l' shows that each entry in the 'files' array shows up as a file, some R/O, some R/W, one W/O. The 'getTimestampFunc in the 'get' function position shows that a special function can be associated with a file to perform calculate repsonses.
ribo@box:~/c$ ls -l /ssm/fuse
total 0
-rw-r--r-- 1 ribo ribo 10 Dec 28 17:17 mode
-rw-r--r-- 1 ribo ribo 1 Dec 28 17:17 numbProcs
--w------- 1 ribo ribo 3 Dec 28 17:17 somethingWO
-rw-r--r-- 1 ribo ribo 5 Dec 28 17:17 svrHostPort
-r--r--r-- 1 ribo ribo 32 Dec 28 17:17 timestamp
ribo@box:~/c$ cat /ssm/fuse/timestamp
18/12/28 17:17:27ribo@box:~/c$cat /ssm/fuse/mode
hyperSpeedribo@box:~/c$ echo slow >/ssm/fuse/mode
ribo@box:~/c$ cat /ssm/fuse/mode
slow
The 'echo >' shows passing a value into the program. So its easy for me to peek and poke various parameters of the program as it runs.
fuse sysfs procfs
fuse sysfs procfs
edited Dec 28 '18 at 22:29
Ribo
asked Dec 27 '18 at 14:53
RiboRibo
1197
1197
1
I don't understand the question. Yes, you can mount a fuse filesystem under /proc or /sys, or even in place of them (see: lxcfs). The question is why you would want to do this when you can just as easily mount a filesystem in /run/myapp or similar?
– CameronNemo
Dec 29 '18 at 5:00
@CameronNemo -- Original purpose of question was to find a means to query/poke parameters in a long running program. My guess was adding a directory or a couple files to /proc or /sys would be easy and effective -- rather than using pipes, socket etc. I ended up creating my own fuse mount to do it. I hoped adding on to /sys or /proc would be simpler.
– Ribo
Dec 30 '18 at 16:26
add a comment |
1
I don't understand the question. Yes, you can mount a fuse filesystem under /proc or /sys, or even in place of them (see: lxcfs). The question is why you would want to do this when you can just as easily mount a filesystem in /run/myapp or similar?
– CameronNemo
Dec 29 '18 at 5:00
@CameronNemo -- Original purpose of question was to find a means to query/poke parameters in a long running program. My guess was adding a directory or a couple files to /proc or /sys would be easy and effective -- rather than using pipes, socket etc. I ended up creating my own fuse mount to do it. I hoped adding on to /sys or /proc would be simpler.
– Ribo
Dec 30 '18 at 16:26
1
1
I don't understand the question. Yes, you can mount a fuse filesystem under /proc or /sys, or even in place of them (see: lxcfs). The question is why you would want to do this when you can just as easily mount a filesystem in /run/myapp or similar?
– CameronNemo
Dec 29 '18 at 5:00
I don't understand the question. Yes, you can mount a fuse filesystem under /proc or /sys, or even in place of them (see: lxcfs). The question is why you would want to do this when you can just as easily mount a filesystem in /run/myapp or similar?
– CameronNemo
Dec 29 '18 at 5:00
@CameronNemo -- Original purpose of question was to find a means to query/poke parameters in a long running program. My guess was adding a directory or a couple files to /proc or /sys would be easy and effective -- rather than using pipes, socket etc. I ended up creating my own fuse mount to do it. I hoped adding on to /sys or /proc would be simpler.
– Ribo
Dec 30 '18 at 16:26
@CameronNemo -- Original purpose of question was to find a means to query/poke parameters in a long running program. My guess was adding a directory or a couple files to /proc or /sys would be easy and effective -- rather than using pipes, socket etc. I ended up creating my own fuse mount to do it. I hoped adding on to /sys or /proc would be simpler.
– Ribo
Dec 30 '18 at 16:26
add a comment |
2 Answers
2
active
oldest
votes
I don’t think there’s any way to add /sys
or /proc
entries outside the kernel. For /sys
it wouldn’t make much sense anyway — it’s a direct representation of kobject data structures.
You can however provide similar interfaces from userspace, for example using FIFOs; see mkfifo
for details. You can see an implementation of this in sysvinit
with its initctl
FIFO.
Yes, mkfifo files are sort of like a socket, and could be used, but there is a lot of work for the daemon/long running program to have a thread to wait for incoming data and parse the request. I liked the callbacks you get in fuse-like virtual file systems, and the file system model provides sorting out different requests (ie different file names would be for different values)
– Ribo
Dec 27 '18 at 15:17
add a comment |
Surely they can. You can mount anything (actual disk filesystems, fuse filesystems, overlayfs, tmpfs, bind mounts, etc) below /sys
or /proc
, extending and/or replacing the interfaces provided by the kernel.
Whether that's a good idea, it's a completely different matter.
Example:
# unshare -m
# touch /tmp/foo
# mount -B /tmp/foo /proc/1/status
# echo FOR GREAT JUSTICE > /proc/1/status
# cat /proc/1/status
This is not what the question is asking, you're just abusing the ambiguity of human language.
– 炸鱼薯条德里克
Dec 29 '18 at 0:47
That's exactly what the question was asking. Go read it again. I used a bind mount for simplicity's sake, I could've made a simple fuse mimicking an actual part of sysfs or procfs and have it mounted below/proc
. But if you're actually able to read OP's mind (no matter how), please edit the question and the title to reflect that (eg. "Can a filesystem be implemented in userspace?").
– mosvy
Dec 29 '18 at 3:57
Read the title again, it's about adding new entries insysfs
orprocfs
, that's the intent, not any arbitary filesystem mounted at/sys
or/proc
.
– 炸鱼薯条德里克
Dec 29 '18 at 4:13
No. You can mount a different fs under /proc or /sys to "provide procfs or sysfs" (that's what cgroupfs and binfmt_misc are doing, and you can do the same from userland, which was point of my answer). But if you really know the actual OP's intent, don't argue with me, but edit the question and the title to reflect that (and move the sample fuse implementation into an answer, where it belongs).
– mosvy
Dec 29 '18 at 4:20
You can't provideprocfs
from userland, you can only provide/proc
, that's different. Most distros is configured that they're the same doesn't mean they HAVE TO be the same.
– 炸鱼薯条德里克
Dec 29 '18 at 4:25
|
show 1 more comment
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491140%2fcan-user-space-programs-provide-implement-sysfs-or-procfs-files-to-pass-data-to%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don’t think there’s any way to add /sys
or /proc
entries outside the kernel. For /sys
it wouldn’t make much sense anyway — it’s a direct representation of kobject data structures.
You can however provide similar interfaces from userspace, for example using FIFOs; see mkfifo
for details. You can see an implementation of this in sysvinit
with its initctl
FIFO.
Yes, mkfifo files are sort of like a socket, and could be used, but there is a lot of work for the daemon/long running program to have a thread to wait for incoming data and parse the request. I liked the callbacks you get in fuse-like virtual file systems, and the file system model provides sorting out different requests (ie different file names would be for different values)
– Ribo
Dec 27 '18 at 15:17
add a comment |
I don’t think there’s any way to add /sys
or /proc
entries outside the kernel. For /sys
it wouldn’t make much sense anyway — it’s a direct representation of kobject data structures.
You can however provide similar interfaces from userspace, for example using FIFOs; see mkfifo
for details. You can see an implementation of this in sysvinit
with its initctl
FIFO.
Yes, mkfifo files are sort of like a socket, and could be used, but there is a lot of work for the daemon/long running program to have a thread to wait for incoming data and parse the request. I liked the callbacks you get in fuse-like virtual file systems, and the file system model provides sorting out different requests (ie different file names would be for different values)
– Ribo
Dec 27 '18 at 15:17
add a comment |
I don’t think there’s any way to add /sys
or /proc
entries outside the kernel. For /sys
it wouldn’t make much sense anyway — it’s a direct representation of kobject data structures.
You can however provide similar interfaces from userspace, for example using FIFOs; see mkfifo
for details. You can see an implementation of this in sysvinit
with its initctl
FIFO.
I don’t think there’s any way to add /sys
or /proc
entries outside the kernel. For /sys
it wouldn’t make much sense anyway — it’s a direct representation of kobject data structures.
You can however provide similar interfaces from userspace, for example using FIFOs; see mkfifo
for details. You can see an implementation of this in sysvinit
with its initctl
FIFO.
answered Dec 27 '18 at 15:12
Stephen KittStephen Kitt
165k24366446
165k24366446
Yes, mkfifo files are sort of like a socket, and could be used, but there is a lot of work for the daemon/long running program to have a thread to wait for incoming data and parse the request. I liked the callbacks you get in fuse-like virtual file systems, and the file system model provides sorting out different requests (ie different file names would be for different values)
– Ribo
Dec 27 '18 at 15:17
add a comment |
Yes, mkfifo files are sort of like a socket, and could be used, but there is a lot of work for the daemon/long running program to have a thread to wait for incoming data and parse the request. I liked the callbacks you get in fuse-like virtual file systems, and the file system model provides sorting out different requests (ie different file names would be for different values)
– Ribo
Dec 27 '18 at 15:17
Yes, mkfifo files are sort of like a socket, and could be used, but there is a lot of work for the daemon/long running program to have a thread to wait for incoming data and parse the request. I liked the callbacks you get in fuse-like virtual file systems, and the file system model provides sorting out different requests (ie different file names would be for different values)
– Ribo
Dec 27 '18 at 15:17
Yes, mkfifo files are sort of like a socket, and could be used, but there is a lot of work for the daemon/long running program to have a thread to wait for incoming data and parse the request. I liked the callbacks you get in fuse-like virtual file systems, and the file system model provides sorting out different requests (ie different file names would be for different values)
– Ribo
Dec 27 '18 at 15:17
add a comment |
Surely they can. You can mount anything (actual disk filesystems, fuse filesystems, overlayfs, tmpfs, bind mounts, etc) below /sys
or /proc
, extending and/or replacing the interfaces provided by the kernel.
Whether that's a good idea, it's a completely different matter.
Example:
# unshare -m
# touch /tmp/foo
# mount -B /tmp/foo /proc/1/status
# echo FOR GREAT JUSTICE > /proc/1/status
# cat /proc/1/status
This is not what the question is asking, you're just abusing the ambiguity of human language.
– 炸鱼薯条德里克
Dec 29 '18 at 0:47
That's exactly what the question was asking. Go read it again. I used a bind mount for simplicity's sake, I could've made a simple fuse mimicking an actual part of sysfs or procfs and have it mounted below/proc
. But if you're actually able to read OP's mind (no matter how), please edit the question and the title to reflect that (eg. "Can a filesystem be implemented in userspace?").
– mosvy
Dec 29 '18 at 3:57
Read the title again, it's about adding new entries insysfs
orprocfs
, that's the intent, not any arbitary filesystem mounted at/sys
or/proc
.
– 炸鱼薯条德里克
Dec 29 '18 at 4:13
No. You can mount a different fs under /proc or /sys to "provide procfs or sysfs" (that's what cgroupfs and binfmt_misc are doing, and you can do the same from userland, which was point of my answer). But if you really know the actual OP's intent, don't argue with me, but edit the question and the title to reflect that (and move the sample fuse implementation into an answer, where it belongs).
– mosvy
Dec 29 '18 at 4:20
You can't provideprocfs
from userland, you can only provide/proc
, that's different. Most distros is configured that they're the same doesn't mean they HAVE TO be the same.
– 炸鱼薯条德里克
Dec 29 '18 at 4:25
|
show 1 more comment
Surely they can. You can mount anything (actual disk filesystems, fuse filesystems, overlayfs, tmpfs, bind mounts, etc) below /sys
or /proc
, extending and/or replacing the interfaces provided by the kernel.
Whether that's a good idea, it's a completely different matter.
Example:
# unshare -m
# touch /tmp/foo
# mount -B /tmp/foo /proc/1/status
# echo FOR GREAT JUSTICE > /proc/1/status
# cat /proc/1/status
This is not what the question is asking, you're just abusing the ambiguity of human language.
– 炸鱼薯条德里克
Dec 29 '18 at 0:47
That's exactly what the question was asking. Go read it again. I used a bind mount for simplicity's sake, I could've made a simple fuse mimicking an actual part of sysfs or procfs and have it mounted below/proc
. But if you're actually able to read OP's mind (no matter how), please edit the question and the title to reflect that (eg. "Can a filesystem be implemented in userspace?").
– mosvy
Dec 29 '18 at 3:57
Read the title again, it's about adding new entries insysfs
orprocfs
, that's the intent, not any arbitary filesystem mounted at/sys
or/proc
.
– 炸鱼薯条德里克
Dec 29 '18 at 4:13
No. You can mount a different fs under /proc or /sys to "provide procfs or sysfs" (that's what cgroupfs and binfmt_misc are doing, and you can do the same from userland, which was point of my answer). But if you really know the actual OP's intent, don't argue with me, but edit the question and the title to reflect that (and move the sample fuse implementation into an answer, where it belongs).
– mosvy
Dec 29 '18 at 4:20
You can't provideprocfs
from userland, you can only provide/proc
, that's different. Most distros is configured that they're the same doesn't mean they HAVE TO be the same.
– 炸鱼薯条德里克
Dec 29 '18 at 4:25
|
show 1 more comment
Surely they can. You can mount anything (actual disk filesystems, fuse filesystems, overlayfs, tmpfs, bind mounts, etc) below /sys
or /proc
, extending and/or replacing the interfaces provided by the kernel.
Whether that's a good idea, it's a completely different matter.
Example:
# unshare -m
# touch /tmp/foo
# mount -B /tmp/foo /proc/1/status
# echo FOR GREAT JUSTICE > /proc/1/status
# cat /proc/1/status
Surely they can. You can mount anything (actual disk filesystems, fuse filesystems, overlayfs, tmpfs, bind mounts, etc) below /sys
or /proc
, extending and/or replacing the interfaces provided by the kernel.
Whether that's a good idea, it's a completely different matter.
Example:
# unshare -m
# touch /tmp/foo
# mount -B /tmp/foo /proc/1/status
# echo FOR GREAT JUSTICE > /proc/1/status
# cat /proc/1/status
edited Dec 29 '18 at 4:53
answered Dec 27 '18 at 18:18
mosvymosvy
6,1861425
6,1861425
This is not what the question is asking, you're just abusing the ambiguity of human language.
– 炸鱼薯条德里克
Dec 29 '18 at 0:47
That's exactly what the question was asking. Go read it again. I used a bind mount for simplicity's sake, I could've made a simple fuse mimicking an actual part of sysfs or procfs and have it mounted below/proc
. But if you're actually able to read OP's mind (no matter how), please edit the question and the title to reflect that (eg. "Can a filesystem be implemented in userspace?").
– mosvy
Dec 29 '18 at 3:57
Read the title again, it's about adding new entries insysfs
orprocfs
, that's the intent, not any arbitary filesystem mounted at/sys
or/proc
.
– 炸鱼薯条德里克
Dec 29 '18 at 4:13
No. You can mount a different fs under /proc or /sys to "provide procfs or sysfs" (that's what cgroupfs and binfmt_misc are doing, and you can do the same from userland, which was point of my answer). But if you really know the actual OP's intent, don't argue with me, but edit the question and the title to reflect that (and move the sample fuse implementation into an answer, where it belongs).
– mosvy
Dec 29 '18 at 4:20
You can't provideprocfs
from userland, you can only provide/proc
, that's different. Most distros is configured that they're the same doesn't mean they HAVE TO be the same.
– 炸鱼薯条德里克
Dec 29 '18 at 4:25
|
show 1 more comment
This is not what the question is asking, you're just abusing the ambiguity of human language.
– 炸鱼薯条德里克
Dec 29 '18 at 0:47
That's exactly what the question was asking. Go read it again. I used a bind mount for simplicity's sake, I could've made a simple fuse mimicking an actual part of sysfs or procfs and have it mounted below/proc
. But if you're actually able to read OP's mind (no matter how), please edit the question and the title to reflect that (eg. "Can a filesystem be implemented in userspace?").
– mosvy
Dec 29 '18 at 3:57
Read the title again, it's about adding new entries insysfs
orprocfs
, that's the intent, not any arbitary filesystem mounted at/sys
or/proc
.
– 炸鱼薯条德里克
Dec 29 '18 at 4:13
No. You can mount a different fs under /proc or /sys to "provide procfs or sysfs" (that's what cgroupfs and binfmt_misc are doing, and you can do the same from userland, which was point of my answer). But if you really know the actual OP's intent, don't argue with me, but edit the question and the title to reflect that (and move the sample fuse implementation into an answer, where it belongs).
– mosvy
Dec 29 '18 at 4:20
You can't provideprocfs
from userland, you can only provide/proc
, that's different. Most distros is configured that they're the same doesn't mean they HAVE TO be the same.
– 炸鱼薯条德里克
Dec 29 '18 at 4:25
This is not what the question is asking, you're just abusing the ambiguity of human language.
– 炸鱼薯条德里克
Dec 29 '18 at 0:47
This is not what the question is asking, you're just abusing the ambiguity of human language.
– 炸鱼薯条德里克
Dec 29 '18 at 0:47
That's exactly what the question was asking. Go read it again. I used a bind mount for simplicity's sake, I could've made a simple fuse mimicking an actual part of sysfs or procfs and have it mounted below
/proc
. But if you're actually able to read OP's mind (no matter how), please edit the question and the title to reflect that (eg. "Can a filesystem be implemented in userspace?").– mosvy
Dec 29 '18 at 3:57
That's exactly what the question was asking. Go read it again. I used a bind mount for simplicity's sake, I could've made a simple fuse mimicking an actual part of sysfs or procfs and have it mounted below
/proc
. But if you're actually able to read OP's mind (no matter how), please edit the question and the title to reflect that (eg. "Can a filesystem be implemented in userspace?").– mosvy
Dec 29 '18 at 3:57
Read the title again, it's about adding new entries in
sysfs
or procfs
, that's the intent, not any arbitary filesystem mounted at /sys
or /proc
.– 炸鱼薯条德里克
Dec 29 '18 at 4:13
Read the title again, it's about adding new entries in
sysfs
or procfs
, that's the intent, not any arbitary filesystem mounted at /sys
or /proc
.– 炸鱼薯条德里克
Dec 29 '18 at 4:13
No. You can mount a different fs under /proc or /sys to "provide procfs or sysfs" (that's what cgroupfs and binfmt_misc are doing, and you can do the same from userland, which was point of my answer). But if you really know the actual OP's intent, don't argue with me, but edit the question and the title to reflect that (and move the sample fuse implementation into an answer, where it belongs).
– mosvy
Dec 29 '18 at 4:20
No. You can mount a different fs under /proc or /sys to "provide procfs or sysfs" (that's what cgroupfs and binfmt_misc are doing, and you can do the same from userland, which was point of my answer). But if you really know the actual OP's intent, don't argue with me, but edit the question and the title to reflect that (and move the sample fuse implementation into an answer, where it belongs).
– mosvy
Dec 29 '18 at 4:20
You can't provide
procfs
from userland, you can only provide /proc
, that's different. Most distros is configured that they're the same doesn't mean they HAVE TO be the same.– 炸鱼薯条德里克
Dec 29 '18 at 4:25
You can't provide
procfs
from userland, you can only provide /proc
, that's different. Most distros is configured that they're the same doesn't mean they HAVE TO be the same.– 炸鱼薯条德里克
Dec 29 '18 at 4:25
|
show 1 more comment
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491140%2fcan-user-space-programs-provide-implement-sysfs-or-procfs-files-to-pass-data-to%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I don't understand the question. Yes, you can mount a fuse filesystem under /proc or /sys, or even in place of them (see: lxcfs). The question is why you would want to do this when you can just as easily mount a filesystem in /run/myapp or similar?
– CameronNemo
Dec 29 '18 at 5:00
@CameronNemo -- Original purpose of question was to find a means to query/poke parameters in a long running program. My guess was adding a directory or a couple files to /proc or /sys would be easy and effective -- rather than using pipes, socket etc. I ended up creating my own fuse mount to do it. I hoped adding on to /sys or /proc would be simpler.
– Ribo
Dec 30 '18 at 16:26