9front - general discussion about 9front
 help / color / mirror / Atom feed
From: sirjofri+ml-9front@sirjofri.de
To: 9front@9front.org
Subject: [9front] 9pfid(2): add Qid declaration (patch)
Date: Wed, 06 Jan 2021 11:02:43 +0100	[thread overview]
Message-ID: <DFB7A4D2BC268539461AAAA83A8DC1FF@sirjofri.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]

Hey all,

this patch adds the declaration for the Qid struct to the 9pfid(2) man page.

The Qid struct seems to be used frequently when writing filesystems and it's not described anywhere else in the man pages.
Only the note that it's declared in /sys/include/libc.h:635 in stat(2) but that's all.

sirjofri

.

[-- Attachment #2: Type: text/plain, Size: 4833 bytes --]

diff -r b24b6b01d46a lib/vgadb
--- a/lib/vgadb	Tue Dec 29 19:38:59 2020 +0000
+++ b/lib/vgadb	Wed Jan 06 10:56:36 2021 +0100
@@ -1772,6 +1772,19 @@
 	hsync=- vsync=-
 	lcd=1
 
+t61_60=1400x1050	# 60Hz
+	clock=108
+	shb=1448 ehb=1560 ht=1688
+	vrs=1051 vre=1054 vt=1066
+	hsync=- vsync=-
+	lcd=1
+t61_50=1400x1050	#50 Hz
+	clock=89.97
+	shb=1448 ehb=1560 ht=1688
+	vrs=1051 vre=1054 vt=1066
+	hsync=- vsync=-
+	lcd=1
+
 #
 # NEC LCD2190uXp
 #
diff -r b24b6b01d46a rc/bin/juke
--- a/rc/bin/juke	Tue Dec 29 19:38:59 2020 +0000
+++ b/rc/bin/juke	Wed Jan 06 10:56:36 2021 +0100
@@ -26,7 +26,7 @@
 		sname=$2
 		shift
 	case -*
-		echo usage: juke [-d level] [-tw] [-s srv] [-h srvhost] >[1=2]
+		echo Usage: classical [-d level] [-t] [-h srvhost]
 		exit usage
 	}
 	shift
diff -r b24b6b01d46a sys/man/1/tweak
--- a/sys/man/1/tweak	Tue Dec 29 19:38:59 2020 +0000
+++ b/sys/man/1/tweak	Wed Jan 06 10:56:36 2021 +0100
@@ -155,6 +155,16 @@
 Quit
 .IR tweak .
 The program will complain once about modified but unwritten files.
+.PP
+.I Tweak
+listens to the
+.I plumber
+channel
+.B imageedit
+for filenames as well as image data. Plumbed image data is stored as files in
+.B /tmp
+and is automatically cleaned when exiting
+.IR tweak .
 .SH SOURCE
 .B /sys/src/cmd/tweak.c
 .SH "SEE ALSO"
diff -r b24b6b01d46a sys/man/2/9pfid
--- a/sys/man/2/9pfid	Tue Dec 29 19:38:59 2020 +0000
+++ b/sys/man/2/9pfid	Wed Jan 06 10:56:36 2021 +0100
@@ -14,6 +14,17 @@
 .PP
 .ft L
 .nf
+.ta \w'\fL    'u +\w'\fLuvlong 'u
+typedef struct Qid
+{
+	uvlong	path;
+	ulong	vers;
+	uchar	type;
+} Qid;
+.fi
+.PP
+.ft L
+.nf
 .ta \w'\fL    'u +\w'\fLulong 'u
 typedef struct Fid
 {
diff -r b24b6b01d46a sys/src/cmd/tweak.c
--- a/sys/src/cmd/tweak.c	Tue Dec 29 19:38:59 2020 +0000
+++ b/sys/src/cmd/tweak.c	Wed Jan 06 10:56:36 2021 +0100
@@ -3,8 +3,11 @@
 #include <draw.h>
 #include <cursor.h>
 #include <event.h>
+#include <plumb.h>
 #include <bio.h>
 
+#define Eplumb 128
+
 typedef struct	Thing	Thing;
 
 struct Thing
@@ -157,6 +160,8 @@
 int		but1val = 0;
 int		but2val = 255;
 int		invert = 0;
+int		blockinput = 0;
+int		tmpindex = 0;
 Image		*values[256];
 Image		*greyvalues[256];
 uchar		data[8192];
@@ -172,12 +177,60 @@
 void	tclose1(Thing*);
 
 void
+flushevents(ulong keys)
+{
+	Event e;
+	if(keys == 0)
+		return;
+	while(ecanread(keys))
+		eread(keys, &e);
+}
+
+char*
+pshowdata(Plumbmsg *pm)
+{
+	int fd;
+	char *file;
+	file = smprint("/tmp/tweaktmp.%d.%d", getpid(), tmpindex++);
+	if(file == 0)
+		sysfatal("malloc failed: %r");
+	fd = create(file, OWRITE|OEXCL, 0600);
+	if(fd < 0){
+		free(file);
+		mesg("cannot create tmpfile.");
+		return nil;
+	}
+	if(write(fd, pm->data, pm->ndata) != pm->ndata){
+		mesg("error writing tmpfile: %r");
+		close(fd);
+		free(file);
+		return nil;
+	}
+	close(fd);
+	return file;
+}
+
+char*
+pfilename(Plumbmsg *pm)
+{
+	char *file;
+	if(pm->data[0] == '/')
+		file = smprint("%.*s", pm->ndata, pm->data);
+	else
+		file = smprint("%s/%.*s", pm->wdir, pm->ndata, pm->data);
+	return cleanname(file);
+}
+
+void
 main(int argc, char *argv[])
 {
 	int i;
 	Event e;
 	Thing *t;
+	Plumbmsg *pm;
+	char *s;
 
+	srand(time(0));
 	mag = Mag;
 	if(initdraw(error, 0, "tweak") < 0){
 		fprint(2, "tweak: initdraw failed: %r\n");
@@ -190,6 +243,7 @@
 			drawerror(display, "can't allocate image");
 	}
 	einit(Emouse|Ekeyboard);
+	eplumb(Eplumb, "imageedit");
 	eresized(0);
 	i = 1;
 	setjmp(err);
@@ -214,10 +268,42 @@
 			}
 			if(mouse.buttons & 4)
 				menu();
+			break;
+		case Eplumb:
+			pm = e.v;
+			if(pm->ndata == 0)
+				break;
+			s = plumblookup(pm->attr, "action");
+			if(s && strcmp(s, "showdata") == 0)
+				file = pshowdata(pm);
+			else
+				file = pfilename(pm);
+			if(!file){
+				mesg("invalid plumb data");
+				plumbfree(pm);
+				break;
+			}
+			plumbfree(pm);
+			t = tget(file);
+			if(t)
+				drawthing(t, 1);
+			flushimage(display, 1);
+			file = 0;
 		}
 }
 
 void
+cleantmpfiles(void)
+{
+	char *s;
+	for(tmpindex--; tmpindex >= 0; tmpindex--){
+		s = smprint("/tmp/tweaktmp.%d.%d", getpid(), tmpindex);
+		remove(s);
+		free(s);
+	}
+}
+
+void
 error(Display*, char *s)
 {
 	if(file)
@@ -226,6 +312,7 @@
 		mesg("/dev/bitblt error: %s", s);
 	if(err[0])
 		longjmp(err, 1);
+	cleantmpfiles();
 	exits(s);
 }
 
@@ -531,6 +618,12 @@
 	nt->tr.max.y = nt->tr.min.y + nl;
 	nt->er.max.y = nt->tr.max.y + Border;
 	text(nt);
+
+	mesg("");
+	if(blockinput){
+		flushevents(Emouse|Ekeyboard);
+		blockinput = 0;
+	}
 }
 
 int
@@ -557,6 +650,9 @@
 	uchar buf[256];
 	char *data;
 
+	mesg("reading %s", file);
+	blockinput = 1;
+
 	buf[0] = '\0';
 	errstr((char*)buf, sizeof buf);	/* flush pending error message */
 	memmove(oerr, err, sizeof err);
@@ -2041,6 +2137,7 @@
 		buttons(Down);
 		if(mouse.buttons == 4){
 			buttons(Up);
+			cleantmpfiles();
 			exits(0);
 		}
 		buttons(Up);

             reply	other threads:[~2021-01-06 10:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 10:02 sirjofri+ml-9front [this message]
2021-01-06 10:09 ` sirjofri+ml-9front

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=DFB7A4D2BC268539461AAAA83A8DC1FF@sirjofri.de \
    --to=sirjofri+ml-9front@sirjofri.de \
    --cc=9front@9front.org \
    /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).