From: "adr via 9fans" <9fans@9fans.net>
To: 9fans@9fans.net
Subject: [9fans] Command to set samterm label
Date: Sun, 18 Jul 2021 18:06:46 +0000 (UTC) [thread overview]
Message-ID: <d131be32-8619-527a-56f2-e9315211ee4@SDF.ORG> (raw)
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.h Sat 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*);
-int D_cmd(File*, Cmd*), e_cmd(File*, Cmd*);
-int f_cmd(File*, Cmd*), g_cmd(File*, Cmd*), i_cmd(File*, Cmd*);
-int k_cmd(File*, Cmd*), m_cmd(File*, Cmd*), n_cmd(File*, Cmd*);
-int p_cmd(File*, Cmd*), q_cmd(File*, Cmd*);
-int s_cmd(File*, Cmd*), u_cmd(File*, Cmd*), w_cmd(File*, Cmd*);
-int x_cmd(File*, Cmd*), X_cmd(File*, Cmd*), plan9_cmd(File*, Cmd*);
-int eq_cmd(File*, Cmd*);
+int D_cmd(File*, Cmd*), e_cmd(File*, Cmd*), f_cmd(File*, Cmd*);
+int g_cmd(File*, Cmd*), i_cmd(File*, Cmd*), k_cmd(File*, Cmd*);
+int l_cmd(File*, Cmd*), m_cmd(File*, Cmd*), n_cmd(File*, Cmd*);
+int p_cmd(File*, Cmd*), q_cmd(File*, Cmd*), s_cmd(File*, Cmd*);
+int u_cmd(File*, Cmd*), w_cmd(File*, Cmd*), x_cmd(File*, Cmd*);
+int X_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
next reply other threads:[~2021-07-18 18:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-18 18:06 adr via 9fans [this message]
2021-07-18 20:26 ` umbraticus
2021-07-18 21:58 ` adr via 9fans
2021-07-18 22:39 ` umbraticus
2021-07-19 0:51 ` adr via 9fans
2021-07-19 11:59 ` umbraticus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d131be32-8619-527a-56f2-e9315211ee4@SDF.ORG \
--to=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).