[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to overwrite a symbolic link?
From: |
Peng Yu |
Subject: |
Re: How to overwrite a symbolic link? |
Date: |
Mon, 10 May 2010 08:30:40 -0500 |
On Mon, May 10, 2010 at 6:59 AM, Marc Herbert <Marc.Herbert@gmail.com> wrote:
> Le 07/05/2010 16:02, Peng Yu a écrit :
>> I can copy the whole
>> directory and then modify one file in the newly copied N files. But
>> I'll lose track of which file has been changed later on, which is
>> important to me.
>
> You will not lose track of the changed files: just run a recursive
> diff comparing the old and new directories and you will see what
> was/has changed (this is actually the poor man's version control
> system).
If I have X similar directories that are resulted from the copying and
modifying in the above, I will end up X*(X-1) comparisons. And it is
still hard to figure out the lineage of these X directories from these
X*(X-1) comparisons (because I need to compare diffs of diffs).
Therefore, I think that this is not a viable solution.
>> Suppose I have N files in a directory that does some job. Lets say M
>> (<N) files are primary files and N-M files are derived from these M
>> files (say, there are a number of programs, each takes some of the M
>> files to generate some of the N-M files).
>> [...]
>> Instead, I'd rather create symbolic link for all the N-M-1 primary
>> files but copy only one remaining file and modify it. Remember, I
>> can't tell which are primary files and which are derived files. So I
>> can not do so.
>>
>> One solution is create symbolic link to N-1 files as long as I can
>> overload '>' and '>>' and the open file function call.
>
> So you are really trying to re-invent some copy-on-write/versioning
> file system by hacking symbolic links and redirections. This looks
> like a lot of pain. You'd better start by looking at existing
> solutions; even if none is ideal for your case, you would at least
> leverage the existing knowledge and experience in this field instead
> of starting from zero.
http://en.wikipedia.org/wiki/Versioning_file_system
http://en.wikipedia.org/wiki/Ext3cow
I'm trying to understand how versioning and copy-on-write are relevant
to my cases. But I don't think that they are really relevant to my
cases.
The closest file system that I have used is snapshot (I don't know the
exact technical term, but I remember there is a '.snapshot' directory
in my home, where I can find previous 1 hour, 4 hours, 1 day and 1week
versions of my home directory).
Please correct me if I'm wrong. These versioning file systems
automatically keep different versions (modified at different time) of
the same file, and doesn't allow users to choose which versions to
keep and which version not to keep. This will end up to many versions
that are actually not useful and it would a pain to look for the
actual useful versions. Also I need the same file appear in two
different directories. I think that these versioning systems may not
help me on this aspect unless I use symbolic links. Therefore, the
solution to my particular problem is still in hacking symbolic link.
>> Let me know if you have any thought on solving this problem.
>
> Since you are using the wrong tool for the job I am afraid you are
> going to be rather alone on this road.
For right now, I think that the best solution is, instead of reloading
>, >>, and related system calls, to test symbolic link and rm it and
then write a new file with the same name. The trick of _ function by
Dennis is useful.
--
Regards,
Peng
- Re: How to overwrite a symbolic link?, (continued)
- Re: How to overwrite a symbolic link?, Marc Herbert, 2010/05/07
- Re: How to overwrite a symbolic link?, Peng Yu, 2010/05/07
- Re: How to overwrite a symbolic link?, Eric Blake, 2010/05/07
- Re: How to overwrite a symbolic link?, Peng Yu, 2010/05/07
- Re: How to overwrite a symbolic link?, Eric Blake, 2010/05/07
- Re: How to overwrite a symbolic link?, Peng Yu, 2010/05/09
- Re: How to overwrite a symbolic link?, Chet Ramey, 2010/05/09
- Re: How to overwrite a symbolic link?, Marc Herbert, 2010/05/10
- Re: How to overwrite a symbolic link?,
Peng Yu <=
- Re: How to overwrite a symbolic link?, Bob Proulx, 2010/05/10