-----Original Message----- From: Paul Eggert [mailto:eggert@twinsun.com] Sent: Thursday, March 14, 2002 7:19 PM To: Olson, Arthur David (NCI) Cc: tz@elsie.nci.nih.gov Subject: Re: symlinks
Unfortunately that code won't work if toname is of the form FOO/BAR, where FOO is a symbolic link to some other place in the filesystem.
The simplest fix is to remove the HAVE_SYMLINK code entirely, and to fail if the hard-link call fails. It's one less thing to configure in Makefile and in private.h. But if you want to support situations where hard links don't work, I think it would be simpler and more portable to make a copy instead of a link.
Checking the legislative history, I discovered that the item attached below is what got the symlink ball rolling. What I'm after is something that handles such real-world cases correctly; I'm willing to let non-real-world cases slide. --ado
From OLSONA@dc37a.nci.nih.gov Sat Jan 17 14:32:28 1998 Return-Path: <OLSONA@dc37a.nci.nih.gov> Received: from imc.nih.gov by elsie.nci.nih.gov (4.1/SMI-4.1) id AA06211; Sat, 17 Jan 98 14:32:28 EST Message-Id: <9801171932.AA06211@elsie.nci.nih.gov> Received: by imc.nih.gov with Internet Mail Service (5.0.1458.49) id <DCQ5RJ2X>; Sat, 17 Jan 1998 14:32:17 -0500 From: "Olson, Arthur David" <OLSONA@dc37a.nci.nih.gov> To: 'tz' <tz@elsie.nci.nih.gov>, "'aj@arthur.rhein-neckar.de'" <aj@arthur.rhein-neckar.de> Subject: FW: zic using hardlinks:-( Date: Sat, 17 Jan 1998 14:31:18 -0500 X-Priority: 3 X-Mailer: Internet Mail Service (5.0.1458.49) Status: RO
Andreas Jaeger is not on the time zone list; be sure to include Andreas in any reply. --ado ---------- From: Andreas Jaeger[SMTP:aj@arthur.rhein-neckar.de] Sent: Thursday, January 15, 1998 3:34 PM To: tz@elsie.nci.nih.gov Subject: zic using hardlinks:-( Hi, I received the following bug report for GNU libc. Jochen says that using a hard link doesn't work for his system since /etc and /usr/share are on different filesystems. zic is from tzcode1997h. I see three possibilities: - changing the link call in zic.c to symlink. - if link fails with error EXDEV (oldpath and newpath are not on the same filesystem) retry with a symlink. - leave it the way it is. Should symbolic links used in general or only for localtime? Andreas -- Andreas Jaeger aj@arthur.rhein-neckar.de
Number: 413 Category: libc Synopsis: `zic -l' tries to hard link a file between different disk partitions Confidential: no Severity: non-critical Priority: low Responsible: libc-gnats State: open Class: sw-bug Submitter-Id: unknown Arrival-Date: Thu Jan 15 07:32:17 EST 1998 Last-Modified: Originator: Jochen Voss Organization: Department of Mathematics, University of Kaiserslautern/Germany Release: libc-2.0.6 Environment: Host type: i486-pc-linux-gnu System: Linux tatonka 2.0.33 #2 Fri Jan 9 20:20:45 MET 1998 i486 Architecture: i486
Addons: localedata crypt linuxthreads Build CFLAGS: -O3 -m486 -fomit-frame-pointer Build CC: gcc -B$(common-objpfx) Build shared: yes Build profile: no Build omitfp: no Stdio: libio
Description: The command "zic -l MET" should set the local time zone by linking the file "/usr/share/zoneinfo/MET" to "/etc/localtime". It uses a hard link for this purpose. On my system this fails, because the directories "/etc" and "/usr/share/zoneinfo" are located on different disk partitions on my system. This results in the output
zic: Kann nicht von /usr/share/zoneinfo/MET nach /etc/localtime linken: Ungltiger Link ber Gertegrenzen hinweg when I execaute the above command (obviously I use `LANG=de').
How-To-Repeat: Find a system, which uses disk partitions as described above, and execute the command "zic -l MET". Fix: Modify the code in "time/zic.c" to use symlinks (if available) or to copy the file if the hard link fails. Audit-Trail: Unformatted:
"Olson, Arthur David (NCI)" scripsit:
What I'm after is something that handles such real-world cases correctly; I'm willing to let non-real-world cases slide.
Almost anything could be a real-world case, given the tangles of symbolic links that are often used for backward compatibility. I got into considerable trouble with a program that rewrote /etc/aliases on a system in which that was a symlink for /etc/mail/aliases. I strongly recommend copying. Disk space is cheap, copy times are quick, typically only one file (the one in /etc) is affected. And it works every time. -- John Cowan <jcowan@reutershealth.com> http://www.reutershealth.com I amar prestar aen, han mathon ne nen, http://www.ccil.org/~cowan han mathon ne chae, a han noston ne 'wilith. --Galadriel, _LOTR:FOTR_
"Olson, Arthur David (NCI)" <olsona@dc37a.nci.nih.gov> wrote:
Checking the legislative history, I discovered that the item attached below is what got the symlink ball rolling. What I'm after is something that handles such real-world cases correctly; I'm willing to let non-real-world cases slide. ... The command "zic -l MET" should set the local time zone by linking the file "/usr/share/zoneinfo/MET" to "/etc/localtime". It uses a hard link for this purpose. On my system this fails, because the directories "/etc" and "/usr/share/zoneinfo" are located on different disk partitions on my system.
In this case, we have an absolute pathname for the pointed-to file, so there's no danger in making a symlink. So how about: try hard linking; if that fails with EXDEV, and if we have a full pathname for the pointed-to file, use a symlink. Otherwise give up. Do we generally have absolute paths in real-world cases? paul
From: "Olson, Arthur David (NCI)" <olsona@dc37a.nci.nih.gov> Date: Tue, 19 Mar 2002 09:31:43 -0500
What I'm after is something that handles such real-world cases correctly; I'm willing to let non-real-world cases slide.
How about something like the following algorithm? It should handle the real-world cases. (1) try hard link and exit if this succeds (2) try to make a copy (like "cp"), and exit if this succeeds (3) report a failure One advantage of this approach over symlinks is that cases (1) and (2) have more-similar behavior from the user's point of view, since zic removes any existing hard links to the destination before writing it. A disadvantage of symlinks is that if you later update the source of the symlink, you also update its destination, and this differs in behavior from (1). symlinks don't save much if any disk space here, since the files are so tiny. On my Solaris 8 host, a symlink takes up at least 1024 bytes, and most of the zoneinfo files are smaller than that.
I think symlinks are a preferable form for the /etc/localtime configuration, precisely because updating the source has an effect. i.e. you can install new tzdata with updated information for your locale and not have to re-run zic -l to have it take effect by default. In Linux ext2fs and BSD ffs filesystems, symlinks with short targets are stored directly in the inode and so consume only as much filesystem space as an empty file. That is not to say that storage overhead is an issue to be concerned with, but since you mentioned it.
Date: Tue, 19 Mar 2002 15:36:26 -0800 (PST) From: Paul Eggert <eggert@twinsun.com> Message-ID: <200203192336.g2JNaQi10025@shade.twinsun.com> | How about something like the following algorithm? Personally, I like to copy the file, it allows single user mode to get the correct timezone (since the full set of zone files are elsewhere). But the symlink as the big advantage that it works exactly as you describe as a disadvantage - that is, you update the zone file data, and the data via the symlink gets updated automatically. In effect, that means that "zic -l" is needed only when the zone that is to be the local timezone is changed - updates to the values of the timezone data don't alter it. I suspect that for most users, that's what is most likely desired. kre
<<On Tue, 19 Mar 2002 15:36:26 -0800 (PST), Paul Eggert <eggert@twinsun.com> said:
How about something like the following algorithm? It should handle the real-world cases.
(1) try hard link and exit if this succeds (2) try to make a copy (like "cp"), and exit if this succeeds (3) report a failure
With my OS-vendor hat on, we don't document `zic -l' anywhere, and if anyone asks about it, it's not supported. We support two timezone installation utilities: the full-screen `tzsetup', and `cp'. Another disadvantage to symbolic links that you didn't mention is that, if the zoneinfo repository is not on a single-user filesystem, then localtime() doesn't work when the system is in single-user mode. -GAWollman
participants (7)
-
Garrett Wollman -
John Cowan -
Olson, Arthur David (NCI) -
Paul Eggert -
prj@po.cwru.edu -
Robert Elz -
Roland McGrath