X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Fitime.c;h=aeaaec01f8f9ee8c92ed88d717b398956cc4cdf4;hb=dbb649e870428cffea2583ed34233d0239b80992;hp=cc92bb5b9e1e2a08ea111e95e8379d39bebcd51e;hpb=e4a8bde40a6d8319d1b28e054e1a419ba3df2363;p=dump.git diff --git a/dump/itime.c b/dump/itime.c index cc92bb5..aeaaec0 100644 --- a/dump/itime.c +++ b/dump/itime.c @@ -2,8 +2,8 @@ * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit * Remy Card , 1994-1997 - * Stelian Pop , 1999-2000 - * Stelian Pop - Alcôve , 2000 + * Stelian Pop , 1999-2000 + * Stelian Pop - Alcôve , 2000-2002 */ /*- @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: itime.c,v 1.19 2001/06/18 10:58:28 stelian Exp $"; + "$Id: itime.c,v 1.23 2002/08/01 10:23:26 stelian Exp $"; #endif /* not lint */ #include @@ -55,6 +55,8 @@ static const char rcsid[] = #include #include +#include +#include #ifdef __linux__ #ifdef HAVE_EXT2FS_EXT2_FS_H #include @@ -62,7 +64,6 @@ static const char rcsid[] = #include #endif #include -#include #include #include #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); } @@ -131,8 +137,8 @@ initdumptimes(int createdumpdates) static void readdumptimes(FILE *df) { - register int i; - register struct dumptime *dtwalk; + int i; + struct dumptime *dtwalk; for (;;) { dtwalk = (struct dumptime *)calloc(1, sizeof (struct dumptime)); @@ -158,8 +164,8 @@ readdumptimes(FILE *df) void getdumptime(int createdumpdates) { - register struct dumpdates *ddp; - register int i; + struct dumpdates *ddp; + int i; #ifdef FDEBUG msg("Looking for name %s in dumpdates = %s for level = %c\n", @@ -197,16 +203,20 @@ void putdumptime(void) { FILE *df; - register struct dumpdates *dtwalk; - register int i; + 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;