* Ported to Linux's Second Extended File System as part of the
* dump and restore backup suit
* Remy Card <card@Linux.EU.Org>, 1994-1997
- * Stelian Pop <pop@noos.fr>, 1999-2000
- * Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
+ * Stelian Pop <stelian@popies.net>, 1999-2000
+ * Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
*/
/*-
#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 <config.h>
#include <sys/param.h>
#include <sys/time.h>
+#include <time.h>
+#include <fcntl.h>
#ifdef __linux__
#ifdef HAVE_EXT2FS_EXT2_FS_H
#include <ext2fs/ext2_fs.h>
#include <linux/ext2_fs.h>
#endif
#include <ext2fs/ext2fs.h>
-#include <time.h>
#include <bsdcompat.h>
#include <sys/file.h>
#include <unistd.h>
initdumptimes(int createdumpdates)
{
FILE *df;
+ struct flock lock;
if ((df = fopen(dumpdates, "r")) == NULL) {
if (errno != ENOENT) {
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);
}
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));
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",
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;