Re: [9fans] fd and /srv filesystem
Thanks all for the explanations. I think I understand better now. Chris > On Oct 4, 2023, at 12:06 PM, o...@eigenstate.org wrote: > > Quoth Chris McGee : >> Hi All, >> >> I was thinking about file descriptors in the context of Plan 9. On Unix an >> fd is generally only usable by the current process, and child ones through >> a fork with some special incantation if one wants to communicate one over a >> domain socket. This is possibly for security reasons, avoiding other users' >> processes from trying to guess the fd of a critical file. >> >> It's common practice in Plan 9 to post an fd (sometimes via a pipe) from >> one process to the /srv filesystem so that others can discover it and open >> a comms channel. Does the kernel transform the fd into something when >> posted to /srv so that it can be consumed by any other process in the >> system? >> >> Thanks, >> Chris >> > > it's all just Chans in the kernel; devsrv just provides > a way of giving an open chan a name in the namespace. > -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfaa2554a9b74c479-M5fd43d2e15b927fd76e19b2b Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Problem with outputing from kernel
On Wed, Oct 04, 2023 at 07:18:23AM -0400, dusan3...@gmail.com wrote: > Also I was doing with tail -f /dev/kmesg in the background and without that > /dev/kmesg loses the start of output up to some random moment where it shows > it. Could the problem be that i have too many outputs? try tail +0f /dev/kmesg -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T31db04ef89737d25-M0e9be2ef226b9b14bee99193 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] fd and /srv filesystem
Quoth Chris McGee : > Hi All, > > I was thinking about file descriptors in the context of Plan 9. On Unix an > fd is generally only usable by the current process, and child ones through > a fork with some special incantation if one wants to communicate one over a > domain socket. This is possibly for security reasons, avoiding other users' > processes from trying to guess the fd of a critical file. > > It's common practice in Plan 9 to post an fd (sometimes via a pipe) from > one process to the /srv filesystem so that others can discover it and open > a comms channel. Does the kernel transform the fd into something when > posted to /srv so that it can be consumed by any other process in the > system? > > Thanks, > Chris > it's all just Chans in the kernel; devsrv just provides a way of giving an open chan a name in the namespace. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfaa2554a9b74c479-Mfaf45bf1e56e90cf94f97cb8 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Problem with outputing from kernel
Quoth dusan3...@gmail.com: > I added some logs in /sys/src/9/port/proc.c for some tests of the scheduler, > I want to see at what moments do real time processes take the cpu. I did that > with simple prints with the intention of doing cat /dev/kmesg > someFile > because all the prints are stored there. > > The problem is that the flow of output just randomly stops at times and > continues(only once by test) and i lose some of the output which is really > important. Any ideas why? are you printing from an interrupt context? use iprint for that. also, are you looking for trace(1)? we ship with a tool for showing scheduler decisions. > > Also I was doing with tail -f /dev/kmesg in the background and without that > /dev/kmesg loses the start of output up to some random moment where it shows > it. Could the problem be that i have too many outputs? that's what tail *does*. It shows the tail (by default, last 10 lines) of the file. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T31db04ef89737d25-M5f99acee5813b799ce86afe6 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] fd and /srv filesystem
btw it's very common on unix to share FDs in multi-threaded programs. and all the pain resulting from un-synchronised FD access is available as expected :) On 10/4/23, hiro <23h...@gmail.com> wrote: > file descriptors describe to the kernel which of the files you > previously open()'ed (a syscall) you want to operator on. > > it's not about security: if you want to operate on a file that another > process might have opened before, you have to be careful that the > other process isn't writing to the same location in the file at the > same time. the kernel also keeps offsets for you. > > if you share FDs between multiple processes you might want some > synchronisation like locking. > > On 10/4/23, Chris McGee wrote: >> Hi All, >> >> I was thinking about file descriptors in the context of Plan 9. On Unix >> an >> fd is generally only usable by the current process, and child ones >> through >> a fork with some special incantation if one wants to communicate one over >> a >> domain socket. This is possibly for security reasons, avoiding other >> users' >> processes from trying to guess the fd of a critical file. >> >> It's common practice in Plan 9 to post an fd (sometimes via a pipe) from >> one process to the /srv filesystem so that others can discover it and >> open >> a comms channel. Does the kernel transform the fd into something when >> posted to /srv so that it can be consumed by any other process in the >> system? >> >> Thanks, >> Chris -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfaa2554a9b74c479-Mcf0b3c1629feb1b852c3224d Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] fd and /srv filesystem
file descriptors describe to the kernel which of the files you previously open()'ed (a syscall) you want to operator on. it's not about security: if you want to operate on a file that another process might have opened before, you have to be careful that the other process isn't writing to the same location in the file at the same time. the kernel also keeps offsets for you. if you share FDs between multiple processes you might want some synchronisation like locking. On 10/4/23, Chris McGee wrote: > Hi All, > > I was thinking about file descriptors in the context of Plan 9. On Unix an > fd is generally only usable by the current process, and child ones through > a fork with some special incantation if one wants to communicate one over a > domain socket. This is possibly for security reasons, avoiding other users' > processes from trying to guess the fd of a critical file. > > It's common practice in Plan 9 to post an fd (sometimes via a pipe) from > one process to the /srv filesystem so that others can discover it and open > a comms channel. Does the kernel transform the fd into something when > posted to /srv so that it can be consumed by any other process in the > system? > > Thanks, > Chris -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfaa2554a9b74c479-Md097c18fd19852d1e89a068c Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[9fans] Problem with outputing from kernel
I added some logs in /sys/src/9/port/proc.c for some tests of the scheduler, I want to see at what moments do real time processes take the cpu. I did that with simple prints with the intention of doing cat /dev/kmesg > someFile because all the prints are stored there. The problem is that the flow of output just randomly stops at times and continues(only once by test) and i lose some of the output which is really important. Any ideas why? Also I was doing with tail -f /dev/kmesg in the background and without that /dev/kmesg loses the start of output up to some random moment where it shows it. Could the problem be that i have too many outputs? -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T31db04ef89737d25-Ma028dd0e821a763795e71625 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[9fans] fd and /srv filesystem
Hi All, I was thinking about file descriptors in the context of Plan 9. On Unix an fd is generally only usable by the current process, and child ones through a fork with some special incantation if one wants to communicate one over a domain socket. This is possibly for security reasons, avoiding other users' processes from trying to guess the fd of a critical file. It's common practice in Plan 9 to post an fd (sometimes via a pipe) from one process to the /srv filesystem so that others can discover it and open a comms channel. Does the kernel transform the fd into something when posted to /srv so that it can be consumed by any other process in the system? Thanks, Chris -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfaa2554a9b74c479-M6b518cab901dcf6bf60bd280 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription