[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gfsd]Bug in mv-command
From: |
Michael Mess |
Subject: |
[gfsd]Bug in mv-command |
Date: |
Thu, 24 May 2001 23:00:44 +0200 |
Hi!
I think, I found a bug in the mv-command:
<address@hidden>:/ide/altrechner/test/bug>dir
total 0
<address@hidden>:/ide/altrechner/test/bug>mkdir a
<address@hidden>:/ide/altrechner/test/bug>touch b
<address@hidden>:/ide/altrechner/test/bug>mkdir test
<address@hidden>:/ide/altrechner/test/bug>mv * test/
mv: test/test/a: won't create hard link `test/test' to directory `a'
<address@hidden>:/ide/altrechner/test/bug>dir
total 4
drwxr-xr-x 4 michael users 4096 May 24 22:19 test/
<address@hidden>:/ide/altrechner/test/bug>du -a
0 ./test/b
4 ./test/z
8 ./test
12 .
<address@hidden>:/ide/altrechner/test/bug>rm -rf *
<address@hidden>:/ide/altrechner/test/bug>mkdir z
<address@hidden>:/ide/altrechner/test/bug>touch b
<address@hidden>:/ide/altrechner/test/bug>mkdir test
<address@hidden>:/ide/altrechner/test/bug>mv * test/
mv: cannot move `test' to a subdirectory of itself, `test/test'
<address@hidden>:/ide/altrechner/test/bug>du -a
4 ./test/a
0 ./test/b
0 ./test/test/b
4 ./test/test
12 ./test
16 .
<address@hidden>:/ide/altrechner/test/bug>
I think, the mv should not move to a subdirectory of itself at any
circumstances.
I think that the result (the file b is copied and exists two times then)
is unusable.
If everything is moved in the "test" directory, but the "test" itself is
skipped, then everything would be fine and I would be happy. :-)
This is what I expected to get with the above commands:
<address@hidden>:/ide/altrechner/test/bug>rm -rf *
<address@hidden>:/ide/altrechner/test/bug>mkdir a
<address@hidden>:/ide/altrechner/test/bug>touch b;mkdir test
<address@hidden>:/ide/altrechner/test/bug>echo *
a b test
<address@hidden>:/ide/altrechner/test/bug>mv *
<address@hidden>:/ide/altrechner/test/bug>du -a
4 ./test/a
0 ./test/b
8 ./test
12 .
Note: the "mv *" here did "mv a b test".
Above the "mv * test" did "mv a b test test" which should have the same
result as "mv a b test", except of one error message for the "test"
directory.
In the past it allways skipped all directories which should be moved to
a subdirectory of itself.
But now when it comes to this directory, it should not try to mkdir a
new one (like necessary for filesystem borders), it should check the
path first.
If the path is correct it should be done, but if it is a subdirectory of
itself, it should be omitted.
Strace gives me:
...
stat("test/", {st_mode=0, st_size=0, ...}) = 0
lstat("a", {st_mode=0, st_size=0, ...}) = 0
lstat("test/a", 0xbffff5a4) = -1 ENOENT (No such file or
directory)
rename("a", "test/a") = 0
lstat("b", {st_mode=0, st_size=0, ...}) = 0
lstat("test/b", 0xbffff5a4) = -1 ENOENT (No such file or
directory)
rename("b", "test/b") = 0
lstat("test", {st_mode=0, st_size=0, ...}) = 0
lstat("test/test", 0xbffff5a4) = -1 ENOENT (No such file or
directory)
rename("test", "test/test") = -1 EINVAL (Invalid argument)
mkdir("test/test", 040755) = 0
stat("test/test", {st_mode=0, st_size=0, ...}) = 0
open("/dev/null", O_RDONLY|O_NONBLOCK|0x10000) = -1 ENOTDIR (Not a
directory)
open("test", O_RDONLY|O_NONBLOCK|0x10000) = 3
fstat(3, {st_mode=0, st_size=0, ...}) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
brk(0x8054000) = 0x8054000
getdents(3, /* 5 entries */, 3933) = 68
getdents(3, /* 0 entries */, 3933) = 0
close(3) = 0
lstat("test/a", {st_mode=0, st_size=0, ...}) = 0
write(2, "mv: ", 4mv: ) = 4
write(2, "test/test/a: won\'t create hard "..., 64test/test/a: won't
create hard
link `test/test' to directory `a') = 64
write(2, "\n", 1
) = 1
lstat("test/b", {st_mode=0, st_size=0, ...}) = 0
open("test/b", O_RDONLY) = 3
open("test/test/b", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 4
fstat(4, {st_mode=0, st_size=0, ...}) = 0
fstat(3, {st_mode=0, st_size=0, ...}) = 0
read(3, "", 4096) = 0
close(4) = 0
close(3) = 0
utime("test/test/b", [101/05/24-22:46:53, 101/05/24-22:46:53]) = 0
chown(0x8051d40, 0x3e8, 0x64, 0x400fc0c0, 0x8051d40) = 0
chmod("test/test/b", 0100644) = 0
lstat("test/test", {st_mode=0, st_size=0, ...}) = 0
_exit(1) = ?
Greetings,
Michael
- [gfsd]Bug in mv-command,
Michael Mess <=