Annotation of researchv10no/cmd/uucp/chremdir.c, revision 1.1.1.1

1.1       root        1: /*     /sccs/src/cmd/uucp/s.chremdir.c
                      2:        chremdir.c      1.1     8/30/84 17:37:02
                      3: */
                      4: #include "uucp.h"
                      5: VERSION(@(#)chremdir.c 1.1);
                      6: 
                      7: /*
                      8:  * chremdir(sys)
                      9:  * char        *sys;
                     10:  *
                     11:  * create SPOOL/sys directory and chdir to it
                     12:  * side effect: set RemSpool
                     13:  */
                     14: void
                     15: chremdir(sys)
                     16: char   *sys;
                     17: {
                     18:        int     ret;
                     19: 
                     20:        mkremdir(sys);  /* set RemSpool, makes sure it exists */
                     21:        DEBUG(6, "chdir(%s)\n", RemSpool);
                     22:        ret = chdir(RemSpool);
                     23:        ASSERT(ret == 0, Ct_CHDIR, RemSpool, errno);
                     24:        (void) strcpy(Wrkdir, RemSpool);
                     25:        return;
                     26: }
                     27: 
                     28: /*
                     29:  * mkremdir(sys)
                     30:  * char        *sys;
                     31:  *
                     32:  * create SPOOL/sys directory
                     33:  */
                     34: 
                     35: void
                     36: mkremdir(sys)
                     37: char   *sys;
                     38: {
                     39:        (void) sprintf(RemSpool, "%s/%s", SPOOL, sys);
                     40:        do {
                     41:                (void) mkdirs2(RemSpool, DIRMASK);
                     42:        } while (mkdirlock() == 0);
                     43:        return;
                     44: }
                     45: 
                     46: /*
                     47:  * put a file in the spool directory
                     48:  * so it won't be empty, so rm won't rm it
                     49:  * it's not really a lockfile, but we have good ways of cleaning up
                     50:  */
                     51: 
                     52: #define        HUGE    10000
                     53: 
                     54: static int
                     55: mkdirlock()
                     56: {
                     57:        char buf[BUFSIZ];
                     58:        extern int errno;
                     59: 
                     60:        sprintf(buf, "%s/L.%d", RemSpool, getpid());
                     61:        if (access(buf, 0) >= 0)
                     62:                return (1);
                     63:        if (ulockf(buf, HUGE) != FAIL)
                     64:                return (1);
                     65:        ASSERT(errno == ENOENT, "spool dir screwup", buf, errno);
                     66:        return (0);
                     67: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.