9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: arisawa <arisawa@ar.aichi-u.ac.jp>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] DEL code in file name
Date: Sat,  9 Mar 2013 22:38:21 +0900	[thread overview]
Message-ID: <18ADB858-4CC7-4A12-8408-57552185113E@ar.aichi-u.ac.jp> (raw)

Hello,

DEL code is allowed in file name?

I find the following code in cwfs/sub.c.

/*
 * what are legal characters in a name?
 * only disallow control characters.
 * a) utf avoids control characters.
 * b) '/' may not be the separator
 */
int
checkname(char *n)
{
	int i, c;

	if(n == 0 || *n == 0)
		return Ename;
	if(*n == '.' && (n[1] == 0 || (n[1] == '.' && n[2] == 0)))
		return Edot;
	for(i=1; i<NAMELEN; i++) {
		c = n[i] & 0xff;
		if(c == 0)
			return 0;
		if(c < 040)
			return Ename;
	}
	return Etoolong;
}

I have believed DEL code is one of control code
and should not be allowed in file name.
so I experimented.

maia% cat a.c
#include <u.h>
#include <libc.h>

void
usage(void)
{
	fprint(2,"usage: 8.out [-n] ....\n");
	exits("usage");
}


void
main(int argc, char *argv[])
{	int fd;
	ARGBEGIN{
	default: usage();
	}ARGEND

	//fd = create("a\xffb",OWRITE,0664);// accepted
	//fd = create("",OWRITE,0664);// rejected
	fd = create("\xff",OWRITE,0664);// accepted
	//fd = create("\x07",OWRITE,0664);// rejected
	if(fd < 0)
		sysfatal("not open %r");
	write(fd,"abc",3);
	close(fd);
}

# cwfs64x
term% ls -l
--rw-rw-r-- M 20 arisawa arisawa     3 Mar  9 21:39 ''
--rwxrwxr-x M 20 arisawa arisawa 36671 Mar  9 21:39 8.out
--rw-rw-r-- M 20 arisawa arisawa     3 Mar  2 22:13 a
--rw-rw-r-- M 20 arisawa arisawa  1858 Mar  9 21:39 a.8
--rw-r--r-- M 20 arisawa arisawa   602 Mar  9 21:39 a.c
--rw-rw-r-- M 20 arisawa arisawa  2526 Mar  6 20:59 dirty.txt
--rw-r--r-- M 20 arisawa arisawa   303 Mar  2 22:10 mkfile

# fossil
ar% ls -l
--rwxrwxr-x M 769572 arisawa arisawa 37602 Mar  9 22:18 8.out
--rw-rw-r-- M 769572 arisawa arisawa  1882 Mar  9 22:18 a.8
--rw-r--r-- M 769572 arisawa arisawa  1509 Mar  9 22:18 a.c
--rw-rw-r-- M 769572 arisawa arisawa     3 Mar  9 22:18 a
--rw-rw-r-- M 769572 arisawa arisawa  2526 Mar  6 20:59 dirty.txt
--rw-r--r-- M 769572 arisawa arisawa   303 Mar  2 22:10 mkfile
--rw-rw-r-- M 769572 arisawa arisawa     3 Mar  9 22:16

the result on cwfs64 and fossil are same. DEL code is accepted in file name.
"\xff" appears as zero length name,
"a\xffb" appears as like "a"
both files cannot be removed by rm command.





             reply	other threads:[~2013-03-09 13:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09 13:38 arisawa [this message]
2013-03-09 14:12 ` erik quanstrom
2013-03-09 23:41   ` arisawa

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=18ADB858-4CC7-4A12-8408-57552185113E@ar.aichi-u.ac.jp \
    --to=arisawa@ar.aichi-u.ac.jp \
    --cc=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).