symlinks in zic

Mani Varadarajan mani at be.com
Tue Nov 17 02:00:23 UTC 1998


Dear Time Zone experts,

I incorporated your timezone database into the BeOS last
year. The BeOS file system does not support hard links,
so I had to implement symbolic link support myself. Judging
from the latest version of tzcode, which I just stumbled
upon today, I notice that you have done the same.

I suggest a few changes to your implementation, detailed
in the attached diff.  The problem with how it is right
now is that if zic is invoked as follows:

zic -d foodir <rules files> 

where foodir is a relative and not an absolute path, the 
symbolic links in the timezone database point to bogus
places. (We use relative paths in our build environment
at Be during our daily builds of the BeOS.)

My proposed changes fix this problem. We have used my
modified version of zic for over a year now in production
without any problems.

Please let me know what you think of the changes. I am not
on this list so please keep me on the CC list.

Thanks,
Mani

*** zic.c.old	Mon Nov 16 17:48:18 1998
--- zic.c	Mon Nov 16 16:47:55 1998
***************
*** 605,616 ****
  
  		if (mkdirs(toname) != 0)
  			(void) exit(EXIT_FAILURE);
  		result = link(fromname, toname);
  #if (HAVE_SYMLINK - 0) 
  		if (result != 0) {
! 			result = symlink(fromname, toname);
  			if (result == 0)
  warning(_("hard link failed, symbolic link used"));
  		}
  #endif
  		if (result != 0) {
--- 605,624 ----
  
  		if (mkdirs(toname) != 0)
  			(void) exit(EXIT_FAILURE);
+ 
  		result = link(fromname, toname);
  #if (HAVE_SYMLINK - 0) 
  		if (result != 0) {
! 		        char *s = (char *) tofile;
! 		        register char * symlinkcontents = NULL;
! 		        while ((s = strchr(s+1, '/')) != NULL)
! 			        symlinkcontents = ecatalloc(symlinkcontents, "../");
! 			symlinkcontents = ecatalloc(symlinkcontents, fromfile);
! 
! 			result = symlink(symlinkcontents, toname);
  			if (result == 0)
  warning(_("hard link failed, symbolic link used"));
+ 			ifree(symlinkcontents);
  		}
  #endif
  		if (result != 0) {




More information about the tz mailing list