guy@auspex.UUCP (Guy Harris) (01/13/89)
(By this point it's a UNIX issue, not a B News issue.) > On SysV the mkdir system call makes a directory. You're thinking of "mknod", not "mkdir". S5, prior to S5R3, didn't have a "mkdir" system call. > SysV allows the superuser to create a directory and put in it what he >wishes. BSD decided that convenience wins over power and gave you fsdb >to handle the fancy cases. 1) BSD also has "mknod". It even, from a quick glance at the 4.3BSD code, permits you to make directories, just as the S5 one does (not surprising, since they both inherited it from older versions of UNIX). And no, it doesn't seem to create the "." or ".." entries. SunOS's "mknod" creates directories with "." and ".." entries, but not BSD's. 2) BSD *doesn't* have "fsdb". If you want to make a directory with no "." or ".." entries, you can just use "mknod", or perhaps use "mkdir" and remove the entries by hand - assuming, of course, that you're super-user. > SysV added another mkdir call which also creates the files. This has >been out for some time, since V.2.x, and is in V.3. Are you sure it was in some S5R2 release? Perhaps in some 3B2 release. It was added, at least in part, because S5R3 has the File System Switch, and some file system other than the S5 one might have a reason for not implementing "create a directory" as "create a directory node and then make the '.' and '..' links" (it might not even *have* "." and ".." as links, although it'll have to make them work in pathnames). It was also added because S5R3 has RFS, and super-user access is NOT always granted over the wire, for good reason. RFS wouldn't be very transparent if you couldn't create directories on remote machines, and requiring super-user access to be granted over the wire would not have been an acceptable fix for this problem. >I don't think that making another design decision is "braindead," Deciding not to have a non-privileged function for creating directories is, given the existence of mechanisms such as the VFS and FSS mechanism, and distributed file systems such as NFS and RFS, undesirable. Neither of those existed when the decision was originally made. >Now you know why SysV has mkdir an SU function, because it makes a >directory, with full user control, and the average user is better >off having it done for him. The question is not why is "'mknod' of a directory (NOT 'mkdir'!) an SU function?", it's "why isn't there a NON-su 'create a directory' function?" The answer is largely "nobody thought it was necessary when the systems without it were made." It is necessary now. The "mkdir" call wasn't put in because "the average user is better off having it done for him." The "mkdir" command in systems without the "mkdir" call was set-UID to the super-user, so there already existed a mechanism by which users (average or not) could create directories; however, in more modern environments it had the problems listed above (and also was a nuisance if a set-UID program wanted to create directories with the privileges of its effective user ID rather than its real user ID).