[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patch for "mv -s" option
From: |
Brendan Byrd/SineSwiper |
Subject: |
Re: Patch for "mv -s" option |
Date: |
Mon, 08 Nov 2004 02:11:35 -0500 |
User-agent: |
Mozilla Thunderbird 0.7.2 (Windows/20040707) |
Philip Rowlands wrote:
On Fri, 5 Nov 2004, Brendan Byrd/SineSwiper wrote:
Also, I have a question about how files are moved. Currently, all files
are copied to a new diskspace, and then the old diskspace is removed.
Only when the file is moving across filesystem boundaries.
Try this to see how mv usually behaves:
$ strace -e trace=file mv /tmp/foo /tmp/bar
execve("/bin/mv", ["mv", "a", "/b"], [/* 54 vars */]) = 0
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=32570, ...}) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0755, st_size=1475331, ...}) = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=32058672, ...}) = 0
stat64("/b", 0xbffff4c0) = -1 ENOENT (No such file or
directory)
lstat64("a", {st_mode=S_IFREG|0644, st_size=454656, ...}) = 0
lstat64("/b", 0xbffff280) = -1 ENOENT (No such file or
directory)
rename("a", "/b") = 0
Okay, after looking at the code again, this makes more sense. The copy
routine doubles as a rename command if in move_mode, hence the
"rename_successful" variable.
Paul Eggert wrote:
> Brendan Byrd/SineSwiper <address@hidden> writes:
>
>>I hashed out a patch for mv which is more or less the opposite of the
>>"--symbolic-link" option for cp. Instead of creating symlinks on the
>>destination before the copy, it creates symlinks on the source after
>>the move.
>
> Before we talk about the patch itself (which was not enclosed in your
> email, by the way), could you give an illustration why such an option
> is useful? Often the most important part of such changes is the
> documentation, and the illustration should be put there.
Hmmm...it was in an attachment, according to my Sent file. I guess the
mailing list doesn't support attachments. I could sent it in the
e-mail, but I'm afraid that long lines would get word wrapped. Is there
a place to send attachments/patches?
Sorry, I did forget about the man page, but I can easily add that in.
(The mv --help was changed, though.) I just wanted to release the patch
to see if the idea would be applied. As far as application and
usefulness, three things come to mind:
1. Retaining glob information during a mv/ln. This was my itch to
stratch. I wanted to move IRC *.log files to /var/log/ircd and then
link those to the moved files. Unforunately, after you move them, you
can't just type "ln /var/log/ircd/*.log ." if there are log files
already in the directory other than the ones you move. With the mv -s,
all of the glob information is retained, so it knows exactly which files
get the symlinks.
2. Moving directories from one filesystem to another. A common way of
shifting HD space on a multi-partitioned system is to move a large
directory from the full partition, to area owned by partition with space
to spare, followed by symlinking to the directory. This is made easier
with a "mv -s" command.
3. Better compatibility/completeness with the cp command. In comparison
to the cp command, the mv command is bereft of options. It's probably
true that the cp command has a bunch of little used or legacy options,
but this was one that I thought would have been added to mv already.
--
Brendan Byrd/SineSwiper <address@hidden>
Computer techie, Perl hacker, and all-purpose Internet guru
Resonator Software (http://www.ResonatorSoft.org/)
- Patch for "mv -s" option, Brendan Byrd/SineSwiper, 2004/11/05
- Re: Patch for "mv -s" option, Philip Rowlands, 2004/11/05
- Re: Patch for "mv -s" option,
Brendan Byrd/SineSwiper <=
- Re: Patch for "mv -s" option, Paul Eggert, 2004/11/08
- Re: Patch for "mv -s" option, Paul Eggert, 2004/11/08
- Re: Patch for "mv -s" option, Jim Meyering, 2004/11/08
- Re: Patch for "mv -s" option, Paul Eggert, 2004/11/08
- Re: Patch for "mv -s" option, Jim Meyering, 2004/11/09
- Re: Patch for "mv -s" option, Brendan Byrd/SineSwiper, 2004/11/15
- Re: Patch for "mv -s" option, Paul Eggert, 2004/11/16
- Re: Patch for "mv -s" option, Brendan Byrd/SineSwiper, 2004/11/19
- Re: Patch for "mv -s" option, Brendan Byrd/SineSwiper, 2004/11/19
- Re: Patch for "mv -s" option, Paul Jarc, 2004/11/19