From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 16 Aug 1995 02:39:16 -0400 From: dhog@plan9.cs.su.oz.au dhog@plan9.cs.su.oz.au Subject: [comp.os.linux.misc] Help wanted, Plan9 a piece of junk! Topicbox-Message-UUID: 16bcd054-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19950816063916.1vVsajUrGBnNz1memM4UA--arl7yGQqArG6eKEt5d4o@z> >Love that subject... He can't even spell Linux... ;-) >Since everything in Plan 9 is a file, the message 'file does not >exist' is probably the least useful and most seen message. I've noticed that sometimes the message is printed even when there is no actual file that couldn't be opened. The reason for this appears to be: (1) Some programs use errstr when reporting errors which don't actually set errstr (2) open() can set errstr as a side effect, even when the call succeeds. This is due to the implementation of union directories -- walk() tries each directory in a union in turn until it succeeds, and errstr is set to 'file does not exist' as a side effect of a failed attempt. Thus any program which, say, uses files in /dev, will have errstr set to 'file does not exist' instead of 'no error'. In fact, it's worse than that, since "/" is a union directory, opening any file in the namespace will set errstr! I'm not sure what the best way to fix this is. Ideally, open() should not change errstr at all if it succeeds, but this would require wasteful copying of errstr in every call to walk() on a union directory. The alternative is to just blindly clear u->error[0] on a sucessful open() -- cheaper, but is it The Right Thing? Anyway, here is a program to demonstrate the problem: ----------------- #include #include void try(char *file) { char err[ERRLEN]; strcpy(err, "no error, dude"); fprint(2, "\nbefore opening %s, set errstr = '%s'\n", file, err); errstr(err); if (open(file, OREAD) < 0) fprint(2, "open %s failed!: %r\n", file); else fprint(2, "after opening %s, errstr = '%r'\n", file); } void main(int argc, char *argv[]) { fprint(2, "on program entry, errstr = '%r'\n"); try("/dev/null"); try("/adm/users"); try("#p/1/status"); exits(0); } -------------------- Here's the output when I run it: on program entry, errstr = 'file does not exist' before opening /dev/null, set errstr = 'no error, dude' after opening /dev/null, errstr = 'file does not exist' before opening /adm/users, set errstr = 'no error, dude' after opening /adm/users, errstr = 'file does not exist' before opening #p/1/status, set errstr = 'no error, dude' after opening #p/1/status, errstr = 'no error, dude' -------------------- P.S. If Plan9 is junk, what does that make Windows 3.1?