Standards Update (3 of 4): NBS FIPS

Moderator, John S. Quarterman std-unix at longway.TIC.COM
Thu Feb 18 08:42:48 AEST 1988


From: uunet!harvard.harvard.edu!haddock!karl (Karl Heuer)

In article <130 at longway.TIC.COM> the moderator writes:
>I don't really understand the question, but if it's whether the rename
>function can be used to move directories, the answer is yes (although the
>user command is mv).

On at least one SysV-based system with a rename() system call and with
unprivileged mv command, the following can occur.

$ cat <<\! >rename.c
> main(c,v) char **v; { if (rename(v[1], v[2]) == -1) perror("rename"); }
> !
$ cc rename.c -o rename
$ ls
rename
rename.c
$ mkdir foo
$ mkdir foo/bar
$ mv foo/bar bar
mv: directory rename only
$ ./rename foo/bar bar
$ ls
bar
foo
rename
rename.c
$ ls foo
$ exit

As you can see, even though the system call works properly, `mv' on this
system attempts to enforce a restriction that the only thing you can do with a
directory is a `simple' rename (one where the `..' entry does not change).  My
reinterpretation of John Chamber's question has two parts:

(a) Does the standard require that the rename() function allow non-simple
renames of directories?

(b) Does the standard require that the mv command allow this?

[1003.1 doesn't say anything about mv, because that's in 1003.2.
I don't know offhand what 1003.2 says.  1003.2 people?  -mod]

Volume-Number: Volume 13, Number 18



More information about the Comp.std.unix mailing list