X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/5b6474c58e0da8f5a4768fee398aec91ee293b1d..6b46907fc661bff40f4e36b563413ea83dec49c6:/usr/src/usr.bin/tip/uucplock.c diff --git a/usr/src/usr.bin/tip/uucplock.c b/usr/src/usr.bin/tip/uucplock.c index 99d8a36807..d584f7f15d 100644 --- a/usr/src/usr.bin/tip/uucplock.c +++ b/usr/src/usr.bin/tip/uucplock.c @@ -1,11 +1,11 @@ -/* uucplock.c 4.1 81/05/09 */ +/* uucplock.c 4.5 83/06/15 */ /* * defs that come from uucp.h */ #define NAMESIZE 15 #define FAIL -1 #define SAME 0 -#define SLCKTIME 5400 /* system/device timeout (LCK.. files) in seconds */ +#define SLCKTIME 28800 /* system/device timeout (LCK.. files) in seconds (8 hours) */ #define ASSERT(e, f, v) if (!(e)) {\ fprintf(stderr, "AERROR - (%s) ", "e");\ fprintf(stderr, f, v);\ @@ -26,6 +26,8 @@ #include #include +static char *sccsid = "@(#)uucplock.c 4.5 %G%"; + /******* * ulockf(file, atime) * char *file; @@ -42,8 +44,8 @@ static ulockf(file, atime) -char *file; -time_t atime; + char *file; + time_t atime; { struct stat stbuf; time_t ptime; @@ -63,16 +65,16 @@ time_t atime; time(&ptime); if ((ptime - stbuf.st_ctime) < atime) { /* file not old enough to delete */ - return(FAIL); + return (FAIL); } } ret = unlink(file); ret = onelock(pid, tempfile, file); if (ret != 0) - return(FAIL); + return (FAIL); } stlock(file); - return(0); + return (0); } #define MAXLOCKS 10 /* maximum number of lock files */ @@ -88,7 +90,7 @@ int Nlocks = 0; static stlock(name) -char *name; + char *name; { char *p; extern char *calloc(); @@ -117,21 +119,19 @@ char *name; static rmlock(name) -char *name; + char *name; { int i; for (i = 0; i < Nlocks; i++) { if (Lockfile[i] == NULL) continue; - if (name == NULL - || strcmp(name, Lockfile[i]) == SAME) { + if (name == NULL || strcmp(name, Lockfile[i]) == SAME) { unlink(Lockfile[i]); free(Lockfile[i]); Lockfile[i] = NULL; } } - return; } /* @@ -149,34 +149,34 @@ char *name; */ static isalock(name) -char *name; + char *name; { struct stat xstat; - if(stat(name,&xstat)<0) - return(0); - if(xstat.st_size!=sizeof(int)) - return(0); - return(1); + if (stat(name, &xstat) < 0) + return (0); + if (xstat.st_size != sizeof(int)) + return (0); + return (1); } static -onelock(pid,tempfile,name) -char *tempfile,*name; +onelock(pid, tempfile, name) + char *tempfile, *name; { int fd; - fd=creat(tempfile,0444); - if(fd<0) - return(-1); - write(fd,(char *) &pid,sizeof(int)); + fd = creat(tempfile, 0444); + if (fd < 0) + return (-1); + write(fd,(char *)&pid, sizeof(int)); close(fd); - if(link(tempfile,name)<0) { + if (link(tempfile, name) < 0) { unlink(tempfile); - return(-1); + return (-1); } unlink(tempfile); - return(0); + return (0); } /*** @@ -187,7 +187,7 @@ char *tempfile,*name; */ delock(s) -char *s; + char *s; { char ln[30]; @@ -203,9 +203,9 @@ char *s; */ mlock(sys) -char *sys; + char *sys; { char lname[30]; sprintf(lname, "%s.%s", LOCKPRE, sys); - return(ulockf(lname, (time_t) SLCKTIME ) < 0 ? FAIL : 0); + return (ulockf(lname, (time_t) SLCKTIME ) < 0 ? FAIL : 0); }