diff options
author | jk217608 <none@none> | 2008-05-13 01:37:00 -0700 |
---|---|---|
committer | jk217608 <none@none> | 2008-05-13 01:37:00 -0700 |
commit | 2b52f2afd5bf4e315cee202285165b6ff78cc6c2 (patch) | |
tree | cf9a27b8d0d5bfda6aa393bbf4a5bd2af21d2365 /usr/src/cmd/cron | |
parent | c208cf63cb44eb43a0ba3a8b92b3390964e95cd0 (diff) | |
download | illumos-gate-2b52f2afd5bf4e315cee202285165b6ff78cc6c2.tar.gz |
6577081 atq and atrm fails if /var/spool/cron/atjobs resides on ZFS
Diffstat (limited to 'usr/src/cmd/cron')
-rw-r--r-- | usr/src/cmd/cron/atq.c | 8 | ||||
-rw-r--r-- | usr/src/cmd/cron/atrm.c | 4 | ||||
-rw-r--r-- | usr/src/cmd/cron/cron.h | 3 | ||||
-rw-r--r-- | usr/src/cmd/cron/funcs.c | 92 |
4 files changed, 12 insertions, 95 deletions
diff --git a/usr/src/cmd/cron/atq.c b/usr/src/cmd/cron/atq.c index 37c7db3b58..87fdd3218d 100644 --- a/usr/src/cmd/cron/atq.c +++ b/usr/src/cmd/cron/atq.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -171,7 +171,7 @@ main(int argc, char **argv) */ if (chdir(ATDIR) == -1) atabortperror(ATDIR); - if ((numentries = ascandir(".", &queue, filewanted, + if ((numentries = scandir(".", &queue, filewanted, (cflag) ? creation : execution)) < 0) atabortperror(ATDIR); @@ -453,7 +453,7 @@ printjobname(char *file) /* - * Sort files by queue, time of creation, and sequence. (used by "ascandir") + * Sort files by queue, time of creation, and sequence. (used by "scandir") */ int creation(struct dirent **d1, struct dirent **d2) @@ -490,7 +490,7 @@ creation(struct dirent **d1, struct dirent **d2) } /* - * Sort files by queue, time of execution, and sequence. (used by "ascandir") + * Sort files by queue, time of execution, and sequence. (used by "scandir") */ int execution(struct dirent **d1, struct dirent **d2) diff --git a/usr/src/cmd/cron/atrm.c b/usr/src/cmd/cron/atrm.c index f3f2d39bcd..1f50a19fb0 100644 --- a/usr/src/cmd/cron/atrm.c +++ b/usr/src/cmd/cron/atrm.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -343,7 +343,7 @@ getjoblist(struct dirent ***namelistp, struct stat ***statlistp, /* * Get a list of the files in the spooling area. */ - if ((numjobs = ascandir(".", namelistp, filewanted, sortfunc)) < 0) + if ((numjobs = scandir(".", namelistp, filewanted, sortfunc)) < 0) atabortperror(NOREADDIR); if ((statlist = diff --git a/usr/src/cmd/cron/cron.h b/usr/src/cmd/cron/cron.h index f9b8eacd46..ca824e02bc 100644 --- a/usr/src/cmd/cron/cron.h +++ b/usr/src/cmd/cron/cron.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -99,7 +99,6 @@ void cron_sendmsg(char, char *, char *, char); time_t num(char **); void *xmalloc(size_t); void *xcalloc(size_t, size_t); -int ascandir(char *, struct dirent *(*[]), int (*)(), int (*)()); #ifdef __cplusplus } diff --git a/usr/src/cmd/cron/funcs.c b/usr/src/cmd/cron/funcs.c index 95641aaaf1..84ffbdc07f 100644 --- a/usr/src/cmd/cron/funcs.c +++ b/usr/src/cmd/cron/funcs.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -21,7 +20,7 @@ */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -86,7 +85,8 @@ days_btwn(int m1, int d1, int y1, int m2, int d2, int y2) */ if (d2 > days_in_mon(m2, y2)) { int p; - for (p = 1; ! isleap(y2+YEAR+p); p++); + for (p = 1; ! isleap(y2+YEAR+p); p++) + ; return (p*365 + d2-d1-1); } return (d2-d1-1); @@ -172,8 +172,6 @@ char return (msg); } - - int filewanted(struct dirent *direntry) { @@ -194,86 +192,6 @@ filewanted(struct dirent *direntry) return (1); } -/* - * Scan the directory dirname calling select to make a list of selected - * directory entries then sort using qsort and compare routine dcomp. - * Returns the number of entries and a pointer to a list of pointers to - * struct direct (through namelist). Returns -1 if there were any errors. - */ - - -#ifdef DIRSIZ -#undef DIRSIZ - -#endif -#define DIRSIZ(dp) \ - (dp)->d_reclen - -int -ascandir(dirname, namelist, select, dcomp) - char *dirname; - struct dirent *(*namelist[]); - int (*select)(); - int (*dcomp)(); -{ - struct dirent *d, *p, **names; - int nitems; - char *cp1, *cp2; - struct stat stb; - long arraysz; - DIR *dirp; - - if ((dirp = opendir(dirname)) == NULL) - return (-1); - if (fstat(dirp->dd_fd, &stb) < 0) - return (-1); - - /* - * estimate the array size by taking the size of the directory file - * and dividing it by a multiple of the minimum size entry. - */ - arraysz = (stb.st_size / 24); - names = (struct dirent **)malloc(arraysz * sizeof (struct dirent *)); - if (names == NULL) - return (-1); - - nitems = 0; - while ((d = readdir(dirp)) != NULL) { - if (select != NULL && !(*select)(d)) - continue; /* just selected names */ - - /* - * Make a minimum size copy of the data - */ - p = (struct dirent *)malloc(DIRSIZ(d)); - if (p == NULL) - return (-1); - p->d_ino = d->d_ino; - p->d_reclen = d->d_reclen; - /* p->d_namlen = d->d_namlen; */ - for (cp1 = p->d_name, cp2 = d->d_name; *cp1++ = *cp2++; ); - /* - * Check to make sure the array has space left and - * realloc the maximum size. - */ - if (++nitems >= arraysz) { - if (fstat(dirp->dd_fd, &stb) < 0) - return (-1); /* just might have grown */ - arraysz = stb.st_size / 12; - names = (struct dirent **)realloc((char *)names, - arraysz * sizeof (struct dirent *)); - if (names == NULL) - return (-1); - } - names[nitems-1] = p; - } - (void) closedir(dirp); - if (nitems && dcomp != NULL) - qsort(names, nitems, sizeof (struct dirent *), dcomp); - *namelist = names; - return (nitems); -} - void * xcalloc(size_t nElements, size_t size) { |