X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=dump%2Fitime.c;h=aeaaec01f8f9ee8c92ed88d717b398956cc4cdf4;hp=204fc58fdeb5f5a22e76f71a621757989f412ffa;hb=d86089d1dfe8565a3cf6f9d6e2fe96d29d6ab5f1;hpb=4ae23b5c243fdfc6f986d2a300459b424239e930 diff --git a/dump/itime.c b/dump/itime.c index 204fc58..aeaaec0 100644 --- a/dump/itime.c +++ b/dump/itime.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: itime.c,v 1.22 2002/01/25 15:08:59 stelian Exp $"; + "$Id: itime.c,v 1.23 2002/08/01 10:23:26 stelian Exp $"; #endif /* not lint */ #include @@ -56,6 +56,7 @@ static const char rcsid[] = #include #include #include +#include #ifdef __linux__ #ifdef HAVE_EXT2FS_EXT2_FS_H #include @@ -94,6 +95,7 @@ void initdumptimes(int createdumpdates) { FILE *df; + struct flock lock; if ((df = fopen(dumpdates, "r")) == NULL) { if (errno != ENOENT) { @@ -122,7 +124,11 @@ initdumptimes(int createdumpdates) msg("WARNING: no file `%s'\n", dumpdates); } if (df != NULL) { - (void) flock(fileno(df), LOCK_SH); + memset(&lock, 0, sizeof(lock)); + lock.l_type = F_RDLCK; + if (fcntl(fileno(df), F_SETLKW, &lock) < 0) + quit("cannot set read lock on %s: %s\n", + dumpdates, strerror(errno)); readdumptimes(df); (void) fclose(df); } @@ -200,13 +206,17 @@ putdumptime(void) struct dumpdates *dtwalk; int i; int fd; + struct flock lock; if(uflag == 0) return; if ((df = fopen(dumpdates, "r+")) == NULL) quit("cannot rewrite %s: %s\n", dumpdates, strerror(errno)); fd = fileno(df); - (void) flock(fd, LOCK_EX); + memset(&lock, 0, sizeof(lock)); + lock.l_type = F_WRLCK; + if (fcntl(fd, F_SETLKW, &lock) < 0) + quit("cannot set write lock on %s: %s\n", dumpdates, strerror(errno)); free((char *)ddatev); ddatev = 0; nddates = 0;