shithub: riscv

Download patch

ref: 752a61e301d9ee84e2ce19f954a3519591e8ea96
parent: d7acf13023a4f35f7b20f53bc4ae41fe9ab6ba9c
author: cinap_lenrek <[email protected]>
date: Sun Dec 18 17:05:17 EST 2022

upas/fs, imap4d: make setname() use /proc instead of #p

--- a/sys/src/cmd/upas/fs/fs.c
+++ b/sys/src/cmd/upas/fs/fs.c
@@ -221,18 +221,18 @@
 void
 setname(char **v)
 {
-	char buf[128], buf2[32], *p, *e;
+	char buf[128], *p, *e;
 	int fd, i;
 
+	snprint(buf, sizeof buf, "/proc/%d/args", getpid());
+	if((fd = open(buf, OWRITE)) < 0)
+		return;
 	e = buf + sizeof buf;
 	p = seprint(buf, e, "%s", v[0]);
 	for(i = 0; v[++i]; )
 		p = seprint(p, e, " %s", v[i]);
-	snprint(buf2, sizeof buf2, "#p/%d/args", getpid());
-	if((fd = open(buf2, OWRITE)) >= 0){
-		write(fd, buf, p - buf);
-		close(fd);
-	}
+	write(fd, buf, p - buf);
+	close(fd);
 }
 
 ulong
--- a/sys/src/cmd/upas/imap4d/utils.c
+++ b/sys/src/cmd/upas/imap4d/utils.c
@@ -193,17 +193,18 @@
 void
 setname(char *fmt, ...)
 {
-	char buf[128], buf2[32], *p;
+	char buf[128], *p;
 	int fd;
 	va_list arg;
 
+	snprint(buf, sizeof buf, "/proc/%d/args", getpid());
+	if((fd = open(buf, OWRITE)) < 0)
+		return;
+
 	va_start(arg, fmt);
 	p = vseprint(buf, buf + sizeof buf, fmt, arg);
 	va_end(arg);
 
-	snprint(buf2, sizeof buf2, "#p/%d/args", getpid());
-	if((fd = open(buf2, OWRITE)) >= 0){
-		write(fd, buf, p - buf);
-		close(fd);
-	}
+	write(fd, buf, p - buf);
+	close(fd);
 }