9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] experimental change for devmnt to deal with spaces
@ 2002-07-03 12:40 Fco.J.Ballesteros
  2002-07-03 19:43 ` rob pike, esq.
  0 siblings, 1 reply; 7+ messages in thread
From: Fco.J.Ballesteros @ 2002-07-03 12:40 UTC (permalink / raw)
  To: 9fans

This seems to do it.
I'm using it as an experiment.
BTW, is the UTF8 of 0x00a0 0xa0? I think so, but I'm not sure.

One thing I dont like is that this diff makes devmnt to change the
user supplied names. I think it would be better to do it at
convS2M/convM2S, but that scares me. Any comment on this?

If you hate applying diffs, the whole devmnt is at
http://plan9.escet.urjc.es/who/nemo/devmnt.c

Let me know if this convinces you or you're still dubious or
there's a better way.

hth

diff /n/dump/2002/0703/sys/src/9/port/devmnt.c /sys/src/9/port/devmnt.c
77a78,79
> // Ugly, but where would it be better? Perhaps at convS2M/M2S?
> // that would require a change to 9p.
78a81,122
> importname(char *s)
> {
> 	for(; *s; s++)
> 		if (*s == ' ')
> 			*s=0xa0;
> }
> 
> static void
> exportname(char *s)
> {
> 	for(; *s; s++)
> 		if (*s == 0xa0)
> 			*s=' ';
> }
> 
> static void
> exportstat(uchar *s)
> {
> 	int m;
> 
> 	s += STATFIXLEN - 4 * BIT16SZ;	// first string
> 	m = GBIT16(s);
> 	s += BIT16SZ;
> 	for (; m > 0; m--, s++)
> 		if (*s == 0xa0)
> 			*s=' ';
> }
> 
> static void
> importstat(uchar *s)
> {
> 	int m;
> 
> 	s += STATFIXLEN - 4 * BIT16SZ;	// first string
> 	m = GBIT16(s);
> 	s += BIT16SZ;
> 	for (; m > 0; m--, s++)
> 		if (*s == ' ')
> 			*s=0xa0;
> }
> 
> static void
418a463,465
> 	// ␣
> 	for (i = 0; i < nname; i++)
> 		exportname(name[i]);
421d467
< 
486a533
> 		importstat(dp);	// ␣
510a558
> 		exportname(name);
628a677
> 	exportstat(dp);	// ␣
669a719
> 			importstat(p);	// ␣ 



^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [9fans] experimental change for devmnt to deal with spaces
@ 2002-07-03 17:52 rog
  2002-07-03 20:37 ` FJ Ballesteros
  0 siblings, 1 reply; 7+ messages in thread
From: rog @ 2002-07-03 17:52 UTC (permalink / raw)
  To: 9fans

nemo:
> BTW, is the UTF8 of 0x00a0 0xa0? I think so, but I'm not sure.

no rune above 127 has the same representation in utf8.  (0xa0 is
represented by [0xc2, 0x80]).

that means your job is a little harder as you have to grow the
messages.

but i really don't think this is in the right place, as it affects
*every* user-level implemented fileserver, and it's quite possible
that a fileserver produces in a file names that have been created
inside it.  (e.g.  think of upas/fs, "create mboxname").

however i still think it shouldn't be too bad if done at the
boundaries of the system, where one is less likely to have such things
going on, and where one is notionally crossing a language boundary
anyway (e.g.  one doesn't expect a Windows filesystem to have files
containing filenames in plan 9 format).

rob:
> Change space!

actually i thought i was on the side of *not* changing space!  space
in plan 9 was always a character that could be used to separate
filenames unconditionally; now it's not, and that change affects many
things.

a few things that are affected:

* filenames of the same length no longer take the same number of
characters.

* {ls | sort -f} no longer works.  (in fact sort probably needs to
understand quoting for its field separators, as probably do several
other tools).

* regexps for matching filenames become much more complex, and
non-determinate, as we don't know which characters were inside or
outside the quotes.  acme right-button semantics can never work
properly on quoted filenames.

* greater potential for visual misidentification of distinct
filenames: i think that it's more difficult to pick out the filenames
in:
	'A few very  ''long file'    names 'in the same  '   place
than in:
	A_few_very__'long_file    names in_the_same__   place
(substituting '_' for whatever the "space" char is), as there's an
immediate indication of which spaces are separators and which are part
of the filenames.

* the fact that spaces run together visually provides great
possibilities for ambiguities in filenames (not that that isn't an
issue with unicode anyway :-])

* echo no longer works reliably as a convenient way of selecting filenames:
e.g.
	% echo *.txt
	x.txt y.txt z.txt
	% ls -l
	--rw-rw-r-- M 32 rog rog 1 Jul  3 18:31 x.txt y.txt
	--rw-rw-r-- M 32 rog rog 1 Jul  3 18:31 z.txt

oh well.

  rog.



^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [9fans] experimental change for devmnt to deal with spaces
@ 2002-07-03 21:38 rog
  0 siblings, 0 replies; 7+ messages in thread
From: rog @ 2002-07-03 21:38 UTC (permalink / raw)
  To: 9fans

> What's the problem? Any of you must be aware of something I'm missing.

to continue with the upas/fs example, here's a function that opens a
mailbox and returns a pathname that can be used to access the messages
therein:

void
openmbox(char *path, char *name, char result[])
{
	fprint(open("/mail/fs/ctl", OWRITE), "open %q %q", path, name);
	sprint(result, "/mail/fs/%s", name);
}

imagine the function being called as follows:

{
	char buf[65536];
	openmbox("/mail/box/rog/mbox", "My\x00A0Mailbox", buf);
}

assuming upas/fs doesn't do the same character translation as the
mount driver, any subsequent code that tries to use the returned path
will fail, as the mailbox will have been created in upas/fs's internal
data structures *with* the 0xa0 character; however the mount driver
prevents that character from getting through.

to my mind, the fact that a pure plan 9 program has to be aware of
this convention to work correctly seems to indicate that the best
solution is at the boundaries of the system - i.e.  whereever a plan 9
fileserver interacts with an external name.

that keeps internal invariants simple, and the potential for peril low.

  rog.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-07-03 21:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-03 12:40 [9fans] experimental change for devmnt to deal with spaces Fco.J.Ballesteros
2002-07-03 19:43 ` rob pike, esq.
2002-07-03 14:45   ` Lucio De Re
2002-07-03 15:42   ` FJ Ballesteros
2002-07-03 17:52 rog
2002-07-03 20:37 ` FJ Ballesteros
2002-07-03 21:38 rog

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