Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
i wrote a cpu like client/server for windows (called dos). my code and test environment lived on a microsoft smb server. i ran cifs(1) to get access to this from plan9 and sam. dos(1) allowed me to start an rc(1) running on win32 in the same directory as my current directory on plan9. it also kept my local /dev/wdir up to date with that on windows - massaging paths as needed. all this allowed me to bounce between windows and plan9 fairly transparently like cpu(1) would on plan9. i could also plumb files i saw and plan9 would do the right thing. it should use the cpu(1) protocol but i never got round to it - what i have just works. my current employer uses Macs rather than windows so this has fallen into disuse. i am happy to share if anyone has a use for it. -Steve -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M90430f1d0d3a94dcd370712f Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
if you don't already use drawterm anyway for other reasons, and you only would like to set up ssh, and you already have a working 9p server for linux (like u9fs), i don't think there's an immediate benefit in switching to drawterm. otoh if you already do use drawterm interactively for different reasons, it is probably nice to know that you can abuse ssh to get the same environment as exported by drawterm even when you happen to sit on the wrong side of the pipe sometimes. it's a bunch of inversions of directions, and it sounds complicated. but i already have scripts ready for the use of drawterm, so it came naturally. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-Mf8a2a371ccfd7948c69ca6e3 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
it's still equivalent, obviously you can start drawterm in the background or in some persistent virtual terminal emulator. and yes, both drawterm and ssh will use TCP below, the only difference in the stack for the actual data would be that instead of SSH you would have TLS for encryption. On 7/21/21, Dan Cross wrote: > On Wed, Jul 21, 2021 at 1:32 PM Xiao-Yong Jin wrote: > >> > On Jul 21, 2021, at 12:16 PM, Dan Cross wrote: >> > >> > Nothing prevents you from invoking u9fs over an SSH connection; one >> needn't run it from inetd, and I doubt anyone has in 20 years. >> >> You are right. In that case, the only difference is just that, >> citing hiro, >> >> yes it's a lot of back and forth, but ssh only is needed for >> running >> the process, the data afterwards can use 9p directly. > > > It's unclear what that's supposed to mean. There's obviously still a > transport involved; in one case, that's over (I presume) TLS over a TCP > connection owned by drawterm, in the other, it's a bitstream running over > the SSH protocol over TCP. In the former case, if the drawterm process on > the Linux side dies for whatever reason, your imported resources disappear. > In the latter, if the sshd or u9fs die, same. > > Overall, this seems like abusing drawterm to do what u9fs (or other, > similar userspace 9P servers) was (were) intended to do. > > - Dan C. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-Me7a96cf8efb8514500af667a Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
On Wed, Jul 21, 2021 at 1:32 PM Xiao-Yong Jin wrote: > > On Jul 21, 2021, at 12:16 PM, Dan Cross wrote: > > > > Nothing prevents you from invoking u9fs over an SSH connection; one > needn't run it from inetd, and I doubt anyone has in 20 years. > > You are right. In that case, the only difference is just that, > citing hiro, > > yes it's a lot of back and forth, but ssh only is needed for > running > the process, the data afterwards can use 9p directly. It's unclear what that's supposed to mean. There's obviously still a transport involved; in one case, that's over (I presume) TLS over a TCP connection owned by drawterm, in the other, it's a bitstream running over the SSH protocol over TCP. In the former case, if the drawterm process on the Linux side dies for whatever reason, your imported resources disappear. In the latter, if the sshd or u9fs die, same. Overall, this seems like abusing drawterm to do what u9fs (or other, similar userspace 9P servers) was (were) intended to do. - Dan C. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-Mbefc0794ea49365431f10fc4 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
> This is using ssh to attach to the Linux machine to import it's filesystem > into the plan9 namespace? Wouldn't authenticating from plan9 to Linux over > SSH be independent of drawterm vs u9fs? yes, if you only need files from the filesystem ssh might be sufficient protection. also, with additional use of sshnet you're not missing out against drawterm's /net either. so yes, for many things it can be equivalent. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M08fc0896d2d3b3889375ab02 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
> On Jul 21, 2021, at 12:16 PM, Dan Cross wrote: > > Nothing prevents you from invoking u9fs over an SSH connection; one needn't > run it from inetd, and I doubt anyone has in 20 years. You are right. In that case, the only difference is just that, citing hiro, yes it's a lot of back and forth, but ssh only is needed for running the process, the data afterwards can use 9p directly. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M0420f6421e0b56116336edff Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
On Wed, Jul 21, 2021 at 1:09 PM Xiao-Yong Jin wrote: > > On Jul 21, 2021, at 11:42 AM, Dan Cross wrote: > > > > On Wed, Jul 21, 2021 at 12:17 PM Xiao-Yong Jin > wrote: > > > On Jul 21, 2021, at 11:08 AM, Dan Cross wrote: > > > > ssh linuxpc drawterm -c srvdev.rc > > > > > > > > yes it's a lot of back and forth, but ssh only is needed for running > > > > the process, the data afterwards can use 9p directly. > > > > > > What's the difference between that and using something like u9fs? > > > > auth? > > > > This is using ssh to attach to the Linux machine to import it's > filesystem into the plan9 namespace? Wouldn't authenticating from plan9 to > Linux over SSH be independent of drawterm vs u9fs? > > Drawterm does the proper auth and connect to the plan9 system. > U9fs needs plan9 srv to auth and connect to it. > > If you are running a plan9 system, you probably have your auth > setup. If you have access to a posix system, you probably have ssh > setup and you have access as a normal user, and that enables you > to do ssh and drawterm back. No additional setup required. > > U9fs, on the contrary, states > > It is typically invoked on a Unix machine by > inetd with its standard input and output connected to a net- > work connection, typically TCP on an Ethernet. It typically > runs as user root and multiplexes access to multiple Plan 9 > clients over the single wire. It assumes Plan 9 uids match > Unix login names, and changes to the corresponding Unix > effective uid when processing requests. > > I'm not going to run this and listen on a public interface even if > it does not run as root. > > There are issues with the auth method that u9fs uses, which I'm not > going to discuss here. Nothing prevents you from invoking u9fs over an SSH connection; one needn't run it from inetd, and I doubt anyone has in 20 years. - Dan C. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M19bbcae898047761677de240 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
> On Jul 21, 2021, at 11:42 AM, Dan Cross wrote: > > On Wed, Jul 21, 2021 at 12:17 PM Xiao-Yong Jin wrote: > > On Jul 21, 2021, at 11:08 AM, Dan Cross wrote: > > > ssh linuxpc drawterm -c srvdev.rc > > > > > > yes it's a lot of back and forth, but ssh only is needed for running > > > the process, the data afterwards can use 9p directly. > > > > What's the difference between that and using something like u9fs? > > auth? > > This is using ssh to attach to the Linux machine to import it's filesystem > into the plan9 namespace? Wouldn't authenticating from plan9 to Linux over > SSH be independent of drawterm vs u9fs? Drawterm does the proper auth and connect to the plan9 system. U9fs needs plan9 srv to auth and connect to it. If you are running a plan9 system, you probably have your auth setup. If you have access to a posix system, you probably have ssh setup and you have access as a normal user, and that enables you to do ssh and drawterm back. No additional setup required. U9fs, on the contrary, states It is typically invoked on a Unix machine by inetd with its standard input and output connected to a net- work connection, typically TCP on an Ethernet. It typically runs as user root and multiplexes access to multiple Plan 9 clients over the single wire. It assumes Plan 9 uids match Unix login names, and changes to the corresponding Unix effective uid when processing requests. I'm not going to run this and listen on a public interface even if it does not run as root. There are issues with the auth method that u9fs uses, which I'm not going to discuss here. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-Me0fbfb51e9d00650796490b0 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
On Wed, Jul 21, 2021 at 12:17 PM Xiao-Yong Jin wrote: > > On Jul 21, 2021, at 11:08 AM, Dan Cross wrote: > > > ssh linuxpc drawterm -c srvdev.rc > > > > > > yes it's a lot of back and forth, but ssh only is needed for running > > > the process, the data afterwards can use 9p directly. > > > > What's the difference between that and using something like u9fs? > > auth? > This is using ssh to attach to the Linux machine to import it's filesystem into the plan9 namespace? Wouldn't authenticating from plan9 to Linux over SSH be independent of drawterm vs u9fs? - Dan C. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M2452ff590f92aee3d7e33dfb Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
> On Jul 21, 2021, at 11:08 AM, Dan Cross wrote: > > ssh linuxpc drawterm -c srvdev.rc > > yes it's a lot of back and forth, but ssh only is needed for running > the process, the data afterwards can use 9p directly. > > What's the difference between that and using something like u9fs? auth? -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M0b41c5534d3ffc52dae6bce7 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
On Wed, Jul 21, 2021 at 11:12 AM hiro <23h...@gmail.com> wrote: > if i want to serve files from a linux, i sometimes run drawterm on the > linux, export stuff to an /srv and then access that from the other > side. > > theoretically you can automate that also from the other side, make > some script for the /srv stuff, and run it from 9front via ssh via > drawterm: > > ssh linuxpc drawterm -c srvdev.rc > > yes it's a lot of back and forth, but ssh only is needed for running > the process, the data afterwards can use 9p directly. > What's the difference between that and using something like u9fs? - Dan C. On 7/21/21, Xiao-Yong Jin wrote: > >> On Jul 20, 2021, at 10:52 PM, Lucio De Re wrote: > >> > >> what would > >> it take to serve 9P on Posix (in P9P, in other words) over the > >> network? Fontsrv and gitsrv would be immediate beneficiaries. > > > > Just run it like, > > > > fontsrv -s 'tcp!192.168.9.2!1500' > > > > and I've no idea what gitsrv is. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M0fca6f2faa67aa5a68dafebd Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
if i want to serve files from a linux, i sometimes run drawterm on the linux, export stuff to an /srv and then access that from the other side. theoretically you can automate that also from the other side, make some script for the /srv stuff, and run it from 9front via ssh via drawterm: ssh linuxpc drawterm -c srvdev.rc yes it's a lot of back and forth, but ssh only is needed for running the process, the data afterwards can use 9p directly. On 7/21/21, Xiao-Yong Jin wrote: >> On Jul 20, 2021, at 10:52 PM, Lucio De Re wrote: >> >> what would >> it take to serve 9P on Posix (in P9P, in other words) over the >> network? Fontsrv and gitsrv would be immediate beneficiaries. > > Just run it like, > > fontsrv -s 'tcp!192.168.9.2!1500' > > and I've no idea what gitsrv is. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-Mdb88673fa85a760087940e5e Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
> On Jul 20, 2021, at 10:52 PM, Lucio De Re wrote: > > what would > it take to serve 9P on Posix (in P9P, in other words) over the > network? Fontsrv and gitsrv would be immediate beneficiaries. Just run it like, fontsrv -s 'tcp!192.168.9.2!1500' and I've no idea what gitsrv is. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M58a85fbab67058af61f54848 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
On 7/19/21, Steve Simon wrote: > > my cpu for windows was always incomplete, but good enough that i never > finished it properly. > It's on contrib, is it not? I'll take a peek, if my haphazard priority list allows it :-) > for posix i just use sftpfs or now cinap’s sshftp to import the filesystem > from the posix box as /n/fred and run sam locally (i am a samista rather > than an acmeite) > I am aware. Acme is addictive, warts and all. > i cannot run stuff remotely but i can edit in a nice environment. is this > not enough? > Well, what I have taken to do is to run acme on the remote Posix server (no Windows, I am no masochist, and I can't waste time on the Apple bandwagon) across X forwarding, which is quite a bit on the good side of tolerable. And win is OK for quite a bit of remote command line interaction. I don't think it would pay to build ncurses into that :-). But from my Plan 9 workstation that is absurdly not possible. Or, I have missed a step and I need somebody to rattle me some: what would it take to serve 9P on Posix (in P9P, in other words) over the network? Fontsrv and gitsrv would be immediate beneficiaries. Lucio. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-Mcbfff74b90e907db565b2890 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
Sorry, didn't mean to come off as insisting you had to do it my way (I am guilty of hacking all kinds of things into my own samterm); just wanted to point out there are other ways besides adding a new command to sam. > The next step is add an option (or better an environment variable) > to use the rio snarf buffer directly. There is a patch for this floating around somewhere: perhaps whoever wrote it can chime in. Below is a quick illustration of the other thought I had, having label reflect the most recently topped buffer, in case you are or anyone else is interested. umbraticus diff -u /sys/src/cmd/samterm/main.c ./main.c --- /sys/src/cmd/samterm/main.c Thu Apr 30 10:24:09 2020 +++ ./main.cMon Jul 19 23:36:12 2021 @@ -150,6 +150,7 @@ current(Flayer *nw) { Text *t; + int fd; if(which) flborder(which, 0); @@ -160,8 +161,13 @@ buttons(Up); t = (Text *)nw->user1; t->front = nw->l[0]; - if(t != ) + if(t != ){ work = nw; + if((fd = open("/dev/label", OWRITE)) >= 0){ + fprint(fd, "sam %s", (char*)name[whichmenu(t->tag)] + 1); + close(fd); + } + } } which = nw; } @@ -170,11 +176,15 @@ closeup(Flayer *l) { Text *t=(Text *)l->user1; - int m; + int m, fd; m = whichmenu(t->tag); if(m < 0) return; + if((fd = open("/dev/label", OWRITE)) >= 0){ + write(fd, "sam", 4); + close(fd); + } flclose(l); if(l == which){ which = 0; -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M2dfbf5d65c86fcf89c315484 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
my cpu for windows was always incomplete, but good enough that i never finished it properly. for posix i just use sftpfs or now cinap’s sshftp to import the filesystem from the posix box as /n/fred and run sam locally (i am a samista rather than an acmeite) i cannot run stuff remotely but i can edit in a nice environment. is this not enough? -Steve -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M1d424bd90cc86bc378222ce4 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
I’ve started toying with that very idea Lucio, but I haven’t had much time to really vet the ideas. My work has been specifically for 9front and rcpu > On Jul 18, 2021, at 9:53 PM, Lucio De Re wrote: > > On 7/19/21, adr via 9fans <9fans@9fans.net> wrote: >> [ ...]. Running samterm locally is way more efficient than >> using X forwarding. >> > I have adopted on my Linux (Mint) workstations - plural - the paradigm: > > ssh -fX remote acme -l lib/task.acme # for different tasks > > and it works even remotely pretty adequately. The remotes tend to be > pretty slick Debian servers, but even locally that is a boon (NetBSD > rules the Posix roost in my office). > > What I can't do is to do the same from the Plan 9 workstation that I > still prefer for development. I was bemoaning this in some notes to > myself just before reading the exchange. > > Now, it is very common, even after all these years of Plan 9 use, for > me to miss the wood for the trees. I think, not very deeply, that P9P > "cpu" running on the remote Posix server might be what I need - Plan 9 > SSH and I seem to be sworn enemies and X-fdorwarding is not even a > twinkle in SSH's eye - and here I note that Steve Simon's cpu server > for Windows has not been included in P9P (I heard Steve bring that up, > but I have never explored it as I don't own a Windows platform). > > In short, is it out of the question to cpu into a Posix server to > initiate an acme session, rather than using SSH to forward X? > > Lucio. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M6851a6eec7243162cd9dc1d7 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Posix implementation of Plan 9 cpu(1) (Was: [9fans] Command to set samterm label)
On 7/19/21, adr via 9fans <9fans@9fans.net> wrote: > [ ...]. Running samterm locally is way more efficient than > using X forwarding. > I have adopted on my Linux (Mint) workstations - plural - the paradigm: ssh -fX remote acme -l lib/task.acme # for different tasks and it works even remotely pretty adequately. The remotes tend to be pretty slick Debian servers, but even locally that is a boon (NetBSD rules the Posix roost in my office). What I can't do is to do the same from the Plan 9 workstation that I still prefer for development. I was bemoaning this in some notes to myself just before reading the exchange. Now, it is very common, even after all these years of Plan 9 use, for me to miss the wood for the trees. I think, not very deeply, that P9P "cpu" running on the remote Posix server might be what I need - Plan 9 SSH and I seem to be sworn enemies and X-fdorwarding is not even a twinkle in SSH's eye - and here I note that Steve Simon's cpu server for Windows has not been included in P9P (I heard Steve bring that up, but I have never explored it as I don't own a Windows platform). In short, is it out of the question to cpu into a Posix server to initiate an acme session, rather than using SSH to forward X? Lucio. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T09fcdec9c87bfde4-M980f0728c312f6f6ca5623f2 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
Ok, Let me explain this a little. I don't like this "One X to rule them all" concept, recreating complete interfaces. I would prefer to use one gui, and make the programs integrate in it, rethinking some concepts if necessary. Been able to modify the label is fundamental for this. It's a way to identify the program and show its state. Just the same sam does inside its own duplicated interface. The correct way to do this is respecting the program design. That's why the label must be changed in the samterm side. This little change allows you to open a file with one instance of sam, another file with another instance (just not use plumb to edit...) and be able to identify them, using the gui you already have, rio. And if for example you open another file because you need them stuck side by side (but this should be done by gui, not by the editor...) you still can rename the label manually to reflect the change. The next step is add an option (or better an environment variable) to use the rio snarf buffer directly. If you don't see the point of this, just ignore this thread. I'm sharing this patch just in case someone is so frustrated as me with this design, nothing more. By the way, sam -r allows you to edit remotely a file in a unix system, not only with p9p sam, samterm will drive even the old sam from pkgsrc. Running samterm locally is way more efficient than using X forwarding. Regards, adr. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M4075dd8b5bd996932f445643 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
> That's run by sam, not samterm. Ah, I see; /dev/label is not available to the remote end of sam -r. Do people use sam -r a lot, instead of [r]cpu -c sam? Is it appreciably faster? surely having /mnt/term & local /dev in the namespace is nice? Anyway, I see your point. Still not convinced setting the window label belongs inside the editor (or the editor's wm) since it is a feature of rio... If you use winwatch some have patched it to make setting label more convenient, or you could have a script that does: ; label sam $files; bind /dev/null /dev/label; sam $files I discovered this trick when I wanted my persistent page always to be labeled as such rather than change based on whatever it is displaying. > It's for using multimple instances of sam. Sure, was just pointing out if !label was sufficient you could simplify your patch to just tweaking the initdraw call. (Maybe it would be nice to print all files listed on the command line) On the odd occasion I have multiple sams, I prefer to set the label myself to project1, project2 but having the filename(s) there initially might be nice. You could even get clever and have the label change to reflect the most recently active buffer. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M1e8dc73ec3b6f44f7e047e5b Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
On Mon, 19 Jul 2021, umbrati...@prosimetrum.com wrote: This patch adds a command 'l' to set the label, and sets it at startup as described above. meh; you can already run !label blah from inside sam That's run by sam, not samterm. not sure the label-on-startup adds much? It's for using multimple instances of sam. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M1b37b0e9f704fadce4e61f64 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
Re: [9fans] Command to set samterm label
> This patch adds a command 'l' to set the label, and sets it at > startup as described above. meh; you can already run !label blah from inside sam not sure the label-on-startup adds much… but I guess you could just add that at the call to initdraw. umbraticus -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M8c02d90b20788e858568ad92 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[9fans] Command to set samterm label
Hi, I was hacking sam to set /dev/label to 'sam filename' when one is given to be opened but then I thought that it would be better to make samterm do it, so it'll work when using sam remotely. This patch adds a command 'l' to set the label, and sets it at startup as described above. Regards, adr. --- sys/src/cmd/sam/cmd.c Wed Apr 24 00:06:05 2013 +++ /sys/src/cmd/sam/cmd.c Sun Jul 18 18:23:06 2021 @@ -17,6 +17,7 @@ 'g',0, 1, 0, 'p',aDot, 0, 0, g_cmd, 'i',1, 0, 0, 0, aDot, 0, 0, i_cmd, 'k',0, 0, 0, 0, aDot, 0, 0, k_cmd, + 'l',0, 0, 0, 0, aNo,0, linex, l_cmd, 'm',0, 0, 1, 0, aDot, 0, 0, m_cmd, 'n',0, 0, 0, 0, aNo,0, 0, n_cmd, 'p',0, 0, 0, 0, aDot, 0, 0, p_cmd, --- sys/src/cmd/sam/mesg.h Fri Mar 18 22:33:33 2005 +++ /sys/src/cmd/sam/mesg.h Sun Jul 18 18:25:36 2021 @@ -67,6 +67,7 @@ Hack, /* request acknowledgement */ Hexit, Hplumb, /* return plumb message to terminal - version 1 */ + Hlabel, /* change /dev/label */ HMAX, }Hmesg; typedef struct Header{ --- sys/src/cmd/sam/parse.h Thu Oct 27 15:36:34 2005 +++ /sys/src/cmd/sam/parse.hSat Jul 17 19:55:51 2021 @@ -55,13 +55,12 @@ int nl_cmd(File*, Cmd*), a_cmd(File*, Cmd*), b_cmd(File*, Cmd*); int c_cmd(File*, Cmd*), cd_cmd(File*, Cmd*), d_cmd(File*, Cmd*); -intD_cmd(File*, Cmd*), e_cmd(File*, Cmd*); -intf_cmd(File*, Cmd*), g_cmd(File*, Cmd*), i_cmd(File*, Cmd*); -intk_cmd(File*, Cmd*), m_cmd(File*, Cmd*), n_cmd(File*, Cmd*); -intp_cmd(File*, Cmd*), q_cmd(File*, Cmd*); -ints_cmd(File*, Cmd*), u_cmd(File*, Cmd*), w_cmd(File*, Cmd*); -intx_cmd(File*, Cmd*), X_cmd(File*, Cmd*), plan9_cmd(File*, Cmd*); -inteq_cmd(File*, Cmd*); +intD_cmd(File*, Cmd*), e_cmd(File*, Cmd*), f_cmd(File*, Cmd*); +intg_cmd(File*, Cmd*), i_cmd(File*, Cmd*), k_cmd(File*, Cmd*); +intl_cmd(File*, Cmd*), m_cmd(File*, Cmd*), n_cmd(File*, Cmd*); +intp_cmd(File*, Cmd*), q_cmd(File*, Cmd*), s_cmd(File*, Cmd*); +intu_cmd(File*, Cmd*), w_cmd(File*, Cmd*), x_cmd(File*, Cmd*); +intX_cmd(File*, Cmd*), plan9_cmd(File*, Cmd*), eq_cmd(File*, Cmd*); String*getregexp(int); --- sys/src/cmd/sam/sam.c Tue Dec 6 17:05:45 2005 +++ /sys/src/cmd/sam/sam.c Sat Jul 17 17:01:44 2021 @@ -98,6 +98,8 @@ seq++; if(file.nused) current(file.filepptr[0]); + if(curfile) + outTS(Hlabel, &(curfile->name)); setjmp(mainloop); cmdloop(); trytoquit();/* if we already q'ed, quitok will be TRUE */ --- sys/src/cmd/sam/xec.c Tue Jun 6 02:55:54 2000 +++ /sys/src/cmd/sam/xec.c Sat Jul 17 20:20:41 2021 @@ -154,6 +154,14 @@ } int +l_cmd(File *f, Cmd *cp) +{ + USED(f); + outTS(Hlabel, cp->ctext); + return TRUE; +} + +int m_cmd(File *f, Cmd *cp) { Address addr2; --- sys/src/cmd/samterm/mesg.c Thu Mar 29 19:35:49 2012 +++ /sys/src/cmd/samterm/mesg.c Sat Jul 17 20:28:26 2021 @@ -97,6 +97,7 @@ int i, m; long l; Flayer *lp; + char *str, c; m = inshort(0); l = inlong(2); @@ -106,6 +107,16 @@ default: fprint(2, "type %d\n", type); panic("rcv unknown"); + + case Hlabel: + str = (char *)indata; + if((i = open("/dev/label", OWRITE)) >= 0){ + while((c=*str) == ' ' || c=='\t') + str++; + fprint(i, "%s %s", "sam", str); + close(i); + } + break; case Hversion: hversion = m; -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tf1e211daf823c0e0-M6011c83bf34acbf24c11966a Delivery options: https://9fans.topicbox.com/groups/9fans/subscription