Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Tom Holroyd <tomh@taz.ccs.fau.edu>
To: axp-list@redhat.com
Subject: Re: Is XL300 or EBP41-AN any good?
Date: Wed, 2 Dec 1998 16:06:55 +0900 (JST)	[thread overview]
Message-ID: <Pine.LNX.3.96.981202155822.5075A-100000@bhalpha1.nibh.go.jp> (raw)
In-Reply-To: <Pine.LNX.4.02.9812012342250.21284-100000@irish.spincycle.com>

On Tue, 1 Dec 1998, Robb Romans wrote:

>As a side note, RH 5.2 installed fine, with the updated ramdisk, and the
>existing MILO installed from 5.1. Only problem was the fscking date got
>set to 2018 on lots of files, even though I started the install from a
>running 5.1 system.  The cool little script to fix that posted here didn't
>work on the symlinks.

Right -- utime(2) [and therefore touch(1)] doesn't work on symlinks.  Here
is a solution: delete and recreate all the bad links. 

The following program will do the job for one file, and you can invoke
it thusly (assuming it's called fixlinkdate):
	% find / -type l -exec fixlinkdate {} \;

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>

int main(int argc, char **argv)
{
	int i, y;
	char filename[1024];
	struct stat link;
	struct tm *t;

	if (argc != 2) {
		fprintf(stderr, "usage: %s filename\n", argv[0]);
		exit(-1);
	}

	/* Get the link's target and other details. */

	if ((i = readlink(argv[1], filename, 1023)) < 0) {
		fprintf(stderr, "%s is not a valid symbolic link\n", argv[1]);
		exit(-1);
	}
	filename[i] = 0;

	if (lstat(argv[1], &link) < 0) {
		perror("lstat");
		exit(-1);
	}

	/* Sanity check. */

	t = localtime(&link.st_mtime);
	y = t->tm_year + 1900;
	if (y != 2018) {
		printf("year on %s is %d\n", argv[1], y);
		exit(1);
	}

	/* Delete the symbolic link and recreate it. */

	if (unlink(argv[1]) < 0) {
		perror("unlink");
		exit(-1);
	}
	if (symlink(filename, argv[1]) < 0) {
		perror("symlink");
		exit(-1);
	}

	/* Set the owner back. */

	chown(argv[1], link.st_uid, link.st_gid);
}

Note that this program only recreates links that have a year of 2018,
which was the case for my system also.  You can obviously change that
value to anything.


  reply	other threads:[~1998-12-02  7:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-02  2:11 Is XL300 or EBP41-AN any good? Jeff DeMaagd
1998-12-02  5:48 ` Robb Romans
1998-12-02  7:06   ` Tom Holroyd [this message]
1998-12-02  7:17   ` Bob Taylor
1998-12-02 14:43   ` Setting the date during installation Bill Roman
     [not found] <c=NO%a=TELEMAX%p=DNV%l=SNGVPS06-981201171606Z-33813@sngvps 06.dnvps.com>
1998-12-01 17:34 ` Is XL300 or EBP41-AN any good? Maurice Hilarius
1998-12-02  0:20   ` Peter Petrakis
1998-12-02  4:52 ` Mike
  -- strict thread matches above, loose matches on Subject: below --
1998-12-01 17:16 Bernard Chew, Lai Wan
1998-12-01  0:46 Bernard Chew, Lai Wan
1998-12-01  9:17 ` Robb Romans
1998-12-02  0:05 ` Ryan Kirkpatrick
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox