[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Is XL300 or EBP41-AN any good?
- 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)
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.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]