9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* ftpfs eplf extension
@ 1996-09-29  5:18 Scott
  0 siblings, 0 replies; only message in thread
From: Scott @ 1996-09-29  5:18 UTC (permalink / raw)


The ieft ftp working group has been talking about Dan Bernstein's
easily-parsed-list-format proposal (which can be found at
ftp://koobera.math.uic.edu/pub/docs/RFCEPLF).  I think it's a good
idea, so here's a patch to teach ftpfs to interpret it.  (The ftp site
listed above generates it, if you want an example.)

There are a couple of loose ends.  First, They're still talking about
what character encoding it should use.  The existing ftp spec
prescribes ascii.  Using utf-7 has been proposed to fit within that
constraint.  If they change it to be 8 bit clean then utf-8 could be
used.  We'd prefer that, of course, so this code just assumes that's
what will happen. :-)  Second, there have been suggestions for
communicating the file mode bits.  None of those have been implemented
here, so files are either 777 or 000.  Third, eplf communicates a
unique file identifier which could be used to help with cache
coherence, but isn't.

Enclosed is one new file, and patches to the ftpfs source
relative to the last update.

# To unbundle, run this file
echo eplf-patch
sed 's/.//' >eplf-patch <<'//GO.SYSIN DD eplf-patch'
-% diff /sys/src/cmd/ftpfs/ftpfs.h .
-76a77
-> int	crack_eplf(char*, Dir*, char*, int);
-% diff /sys/src/cmd/ftpfs/mkfile
-7a8
-> 	eplf.$O\
-% diff /sys/src/cmd/ftpfs/proto.c .
-539a540,543
-> 	if (crack_eplf(p, dp, longname, sizeof(longname))) {
-> 		goto finish; /* blech */
-> 	}
->
-739a744
-> finish:
-1224a1230
-> 	char dstr[1024];
-1245a1252
->
-1254c1261,1262
-< 	snprint(msg, sizeof(msg), "%s!%s.%s.%s.%s!%d", net,
----
->
-> 	snprint(dstr, sizeof(dstr), "%s!%s.%s.%s.%s!%d", net,
-1257d1264
-<
-1259c1266
-< 	fd = dial(msg, 0, 0, 0);
----
-> 	fd = dial(dstr, 0, 0, 0);
-1262c1269
-< 			fprint(2, "passive mode connect to %s failed: %r\n", msg);
----
-> 			fprint(2, "passive mode connect to %s failed: %r\n", dstr);
//GO.SYSIN DD eplf-patch
echo eplf.c
sed 's/.//' >eplf.c <<'//GO.SYSIN DD eplf.c'
-#include <u.h>
-#include <libc.h>
-#include "ftpfs.h"
-
-int crack_eplf(char* line, Dir* dp, char* longname, int longsize)
-{
-	int when;
-	unsigned long size;
-
-	if (*line++ != '+')
-		return 0;
-
-	strcpy(dp->uid, "none");
-	strcpy(dp->gid, "none");
-	dp->mode = 0;
-	dp->length = 0;
-	dp->atime = 0;
-	safecpy(longname, "", longsize);
-
-	while (*line) {
-		switch (*line) {
-		case '\t':
-			safecpy(longname, line+1, longsize);
-			return 1;
-		case 's':
-			size = 0;
-			while (*++line && (*line != ','))
-				size = size * 10 + (*line - '0');
-			dp->length = size;
-			break;
-		case 'm':
-			when = 0;
-			while (*++line && (*line != ','))
-				when = when * 10 + (*line - '0');
-			dp->atime = when;
-			break;
-		case 'r':
-			dp->mode = 0777;
-			while (*line) if (*line++ == ',') break;
-			break;
-		case '/':
-			dp->length = 0;
-			dp->mode = CHDIR|0777;
-			while (*line) if (*line++ == ',') break;
-			break;
-		case 'i':
-			/* We should use this to control the cache, */
-			/* but fallthru for now. */
-		default:
-			while (*line) if (*line++ == ',') break;
-			break;
-		}
-	}
-	return 0;
-}
-
//GO.SYSIN DD eplf.c




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-09-29  5:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-29  5:18 ftpfs eplf extension Scott

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).