1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1980, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Robert Elz at The University of Melbourne.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-05-03 21:06:42 +00:00
|
|
|
#if 0
|
1994-05-26 05:23:31 +00:00
|
|
|
#ifndef lint
|
1997-10-13 11:05:07 +00:00
|
|
|
static const char copyright[] =
|
1994-05-26 05:23:31 +00:00
|
|
|
"@(#) Copyright (c) 1980, 1990, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
|
|
|
static char sccsid[] = "@(#)repquota.c 8.1 (Berkeley) 6/6/93";
|
|
|
|
#endif /* not lint */
|
2003-05-03 21:06:42 +00:00
|
|
|
#endif
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Quota report
|
|
|
|
*/
|
|
|
|
#include <sys/param.h>
|
2007-02-04 06:33:15 +00:00
|
|
|
#include <sys/mount.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <ufs/ufs/quota.h>
|
1997-10-13 11:05:07 +00:00
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <fstab.h>
|
|
|
|
#include <grp.h>
|
1997-10-13 11:05:07 +00:00
|
|
|
#include <pwd.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <stdio.h>
|
1997-10-13 11:05:07 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-02-25 07:39:34 +00:00
|
|
|
#include <time.h>
|
1997-10-13 11:05:07 +00:00
|
|
|
#include <unistd.h>
|
1998-06-14 22:56:31 +00:00
|
|
|
#include <utmp.h>
|
|
|
|
|
1999-11-01 04:46:09 +00:00
|
|
|
/* Let's be paranoid about block size */
|
|
|
|
#if 10 > DEV_BSHIFT
|
|
|
|
#define dbtokb(db) \
|
|
|
|
((off_t)(db) >> (10-DEV_BSHIFT))
|
|
|
|
#elif 10 < DEV_BSHIFT
|
|
|
|
#define dbtokb(db) \
|
|
|
|
((off_t)(db) << (DEV_BSHIFT-10))
|
|
|
|
#else
|
|
|
|
#define dbtokb(db) (db)
|
|
|
|
#endif
|
|
|
|
|
1998-06-14 22:56:31 +00:00
|
|
|
#define max(a,b) ((a) >= (b) ? (a) : (b))
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2001-12-10 06:25:35 +00:00
|
|
|
const char *qfname = QUOTAFILENAME;
|
|
|
|
const char *qfextension[] = INITQFNAMES;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
struct fileusage {
|
|
|
|
struct fileusage *fu_next;
|
|
|
|
struct dqblk fu_dqblk;
|
|
|
|
u_long fu_id;
|
|
|
|
char fu_name[1];
|
|
|
|
/* actually bigger */
|
|
|
|
};
|
|
|
|
#define FUHASH 1024 /* must be power of two */
|
|
|
|
struct fileusage *fuhead[MAXQUOTAS][FUHASH];
|
2001-12-10 06:25:35 +00:00
|
|
|
struct fileusage *lookup(u_long, int);
|
|
|
|
struct fileusage *addid(u_long, int, char *);
|
1994-05-26 05:23:31 +00:00
|
|
|
u_long highid[MAXQUOTAS]; /* highest addid()'ed identifier per type */
|
|
|
|
|
|
|
|
int vflag; /* verbose */
|
2002-05-16 02:28:39 +00:00
|
|
|
int aflag; /* all filesystems */
|
2003-07-07 21:41:23 +00:00
|
|
|
int nflag; /* display user/group by id */
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2002-07-11 21:26:41 +00:00
|
|
|
int hasquota(struct fstab *, int, char **);
|
|
|
|
int oneof(char *, char *[], int);
|
|
|
|
int repquota(struct fstab *, int, char *);
|
|
|
|
char *timeprt(time_t);
|
|
|
|
static void usage(void);
|
1997-10-13 11:05:07 +00:00
|
|
|
|
|
|
|
int
|
2002-07-11 21:26:41 +00:00
|
|
|
main(int argc, char **argv)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
register struct fstab *fs;
|
|
|
|
register struct passwd *pw;
|
|
|
|
register struct group *gr;
|
2004-01-22 07:23:36 +00:00
|
|
|
int ch, gflag = 0, uflag = 0, errs = 0;
|
1994-05-26 05:23:31 +00:00
|
|
|
long i, argnum, done = 0;
|
2004-01-22 07:23:36 +00:00
|
|
|
char *qfnp;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2003-07-07 21:41:23 +00:00
|
|
|
while ((ch = getopt(argc, argv, "agnuv")) != -1) {
|
1994-05-26 05:23:31 +00:00
|
|
|
switch(ch) {
|
|
|
|
case 'a':
|
|
|
|
aflag++;
|
|
|
|
break;
|
|
|
|
case 'g':
|
|
|
|
gflag++;
|
|
|
|
break;
|
2003-07-07 21:41:23 +00:00
|
|
|
case 'n':
|
|
|
|
nflag++;
|
|
|
|
break;
|
1994-05-26 05:23:31 +00:00
|
|
|
case 'u':
|
|
|
|
uflag++;
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
vflag++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
if (argc == 0 && !aflag)
|
|
|
|
usage();
|
|
|
|
if (!gflag && !uflag) {
|
|
|
|
if (aflag)
|
|
|
|
gflag++;
|
|
|
|
uflag++;
|
|
|
|
}
|
2003-07-07 21:41:23 +00:00
|
|
|
if (gflag && !nflag) {
|
1994-05-26 05:23:31 +00:00
|
|
|
setgrent();
|
|
|
|
while ((gr = getgrent()) != 0)
|
|
|
|
(void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name);
|
|
|
|
endgrent();
|
|
|
|
}
|
2003-07-07 21:41:23 +00:00
|
|
|
if (uflag && !nflag) {
|
1994-05-26 05:23:31 +00:00
|
|
|
setpwent();
|
|
|
|
while ((pw = getpwent()) != 0)
|
|
|
|
(void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name);
|
|
|
|
endpwent();
|
|
|
|
}
|
|
|
|
setfsent();
|
|
|
|
while ((fs = getfsent()) != NULL) {
|
|
|
|
if (strcmp(fs->fs_vfstype, "ufs"))
|
|
|
|
continue;
|
|
|
|
if (aflag) {
|
|
|
|
if (gflag && hasquota(fs, GRPQUOTA, &qfnp))
|
|
|
|
errs += repquota(fs, GRPQUOTA, qfnp);
|
|
|
|
if (uflag && hasquota(fs, USRQUOTA, &qfnp))
|
|
|
|
errs += repquota(fs, USRQUOTA, qfnp);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
|
|
|
|
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) {
|
|
|
|
done |= 1 << argnum;
|
|
|
|
if (gflag && hasquota(fs, GRPQUOTA, &qfnp))
|
|
|
|
errs += repquota(fs, GRPQUOTA, qfnp);
|
|
|
|
if (uflag && hasquota(fs, USRQUOTA, &qfnp))
|
|
|
|
errs += repquota(fs, USRQUOTA, qfnp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endfsent();
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
if ((done & (1 << i)) == 0)
|
1997-10-13 11:05:07 +00:00
|
|
|
warnx("%s not found in fstab", argv[i]);
|
1994-05-26 05:23:31 +00:00
|
|
|
exit(errs);
|
|
|
|
}
|
|
|
|
|
1997-10-13 11:05:07 +00:00
|
|
|
static void
|
1994-05-26 05:23:31 +00:00
|
|
|
usage()
|
|
|
|
{
|
1997-10-13 11:05:07 +00:00
|
|
|
fprintf(stderr, "%s\n%s\n",
|
2003-07-07 21:41:23 +00:00
|
|
|
"usage: repquota [-v] [-g] [-n] [-u] -a",
|
|
|
|
" repquota [-v] [-g] [-n] [-u] filesystem ...");
|
1994-05-26 05:23:31 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1997-10-13 11:05:07 +00:00
|
|
|
int
|
1994-05-26 05:23:31 +00:00
|
|
|
repquota(fs, type, qfpathname)
|
|
|
|
register struct fstab *fs;
|
|
|
|
int type;
|
|
|
|
char *qfpathname;
|
|
|
|
{
|
|
|
|
register struct fileusage *fup;
|
|
|
|
FILE *qf;
|
|
|
|
u_long id;
|
|
|
|
struct dqblk dqbuf;
|
|
|
|
static struct dqblk zerodqblk;
|
|
|
|
static int warned = 0;
|
|
|
|
static int multiple = 0;
|
|
|
|
|
|
|
|
if (quotactl(fs->fs_file, QCMD(Q_SYNC, type), 0, 0) < 0 &&
|
|
|
|
errno == EOPNOTSUPP && !warned && vflag) {
|
|
|
|
warned++;
|
|
|
|
fprintf(stdout,
|
|
|
|
"*** Warning: Quotas are not compiled into this kernel\n");
|
|
|
|
}
|
|
|
|
if (multiple++)
|
|
|
|
printf("\n");
|
|
|
|
if (vflag)
|
|
|
|
fprintf(stdout, "*** Report for %s quotas on %s (%s)\n",
|
|
|
|
qfextension[type], fs->fs_file, fs->fs_spec);
|
|
|
|
if ((qf = fopen(qfpathname, "r")) == NULL) {
|
1997-10-13 11:05:07 +00:00
|
|
|
warn("%s", qfpathname);
|
1994-05-26 05:23:31 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
for (id = 0; ; id++) {
|
|
|
|
fread(&dqbuf, sizeof(struct dqblk), 1, qf);
|
|
|
|
if (feof(qf))
|
|
|
|
break;
|
|
|
|
if (dqbuf.dqb_curinodes == 0 && dqbuf.dqb_curblocks == 0)
|
|
|
|
continue;
|
|
|
|
if ((fup = lookup(id, type)) == 0)
|
|
|
|
fup = addid(id, type, (char *)0);
|
|
|
|
fup->fu_dqblk = dqbuf;
|
|
|
|
}
|
|
|
|
fclose(qf);
|
2004-12-19 18:02:45 +00:00
|
|
|
printf("%*s Block limits File limits\n",
|
1998-06-14 22:56:31 +00:00
|
|
|
max(UT_NAMESIZE,10), " ");
|
2004-12-19 18:02:45 +00:00
|
|
|
printf("User%*s used soft hard grace used soft hard grace\n",
|
1998-06-14 22:56:31 +00:00
|
|
|
max(UT_NAMESIZE,10), " ");
|
1994-05-26 05:23:31 +00:00
|
|
|
for (id = 0; id <= highid[type]; id++) {
|
|
|
|
fup = lookup(id, type);
|
|
|
|
if (fup == 0)
|
|
|
|
continue;
|
|
|
|
if (fup->fu_dqblk.dqb_curinodes == 0 &&
|
|
|
|
fup->fu_dqblk.dqb_curblocks == 0)
|
|
|
|
continue;
|
2004-12-19 18:02:45 +00:00
|
|
|
printf("%-*s ", max(UT_NAMESIZE,10), fup->fu_name);
|
1999-06-11 10:31:24 +00:00
|
|
|
printf("%c%c %8lu %8lu %8lu %6s",
|
1995-05-30 03:57:47 +00:00
|
|
|
fup->fu_dqblk.dqb_bsoftlimit &&
|
|
|
|
fup->fu_dqblk.dqb_curblocks >=
|
1994-05-26 05:23:31 +00:00
|
|
|
fup->fu_dqblk.dqb_bsoftlimit ? '+' : '-',
|
|
|
|
fup->fu_dqblk.dqb_isoftlimit &&
|
|
|
|
fup->fu_dqblk.dqb_curinodes >=
|
|
|
|
fup->fu_dqblk.dqb_isoftlimit ? '+' : '-',
|
1999-11-01 04:46:09 +00:00
|
|
|
(u_long)(dbtokb(fup->fu_dqblk.dqb_curblocks)),
|
|
|
|
(u_long)(dbtokb(fup->fu_dqblk.dqb_bsoftlimit)),
|
|
|
|
(u_long)(dbtokb(fup->fu_dqblk.dqb_bhardlimit)),
|
1995-05-30 03:57:47 +00:00
|
|
|
fup->fu_dqblk.dqb_bsoftlimit &&
|
|
|
|
fup->fu_dqblk.dqb_curblocks >=
|
1994-05-26 05:23:31 +00:00
|
|
|
fup->fu_dqblk.dqb_bsoftlimit ?
|
2001-06-19 00:47:24 +00:00
|
|
|
timeprt(fup->fu_dqblk.dqb_btime) : "-");
|
1999-06-11 10:31:24 +00:00
|
|
|
printf(" %7lu %7lu %7lu %6s\n",
|
2001-12-10 06:25:35 +00:00
|
|
|
(u_long)fup->fu_dqblk.dqb_curinodes,
|
|
|
|
(u_long)fup->fu_dqblk.dqb_isoftlimit,
|
|
|
|
(u_long)fup->fu_dqblk.dqb_ihardlimit,
|
1994-05-26 05:23:31 +00:00
|
|
|
fup->fu_dqblk.dqb_isoftlimit &&
|
|
|
|
fup->fu_dqblk.dqb_curinodes >=
|
|
|
|
fup->fu_dqblk.dqb_isoftlimit ?
|
2001-06-19 00:47:24 +00:00
|
|
|
timeprt(fup->fu_dqblk.dqb_itime) : "-");
|
1994-05-26 05:23:31 +00:00
|
|
|
fup->fu_dqblk = zerodqblk;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to see if target appears in list of size cnt.
|
|
|
|
*/
|
1997-10-13 11:05:07 +00:00
|
|
|
int
|
1994-05-26 05:23:31 +00:00
|
|
|
oneof(target, list, cnt)
|
|
|
|
register char *target, *list[];
|
|
|
|
int cnt;
|
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
for (i = 0; i < cnt; i++)
|
|
|
|
if (strcmp(target, list[i]) == 0)
|
|
|
|
return (i);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to see if a particular quota is to be enabled.
|
|
|
|
*/
|
1997-10-13 11:05:07 +00:00
|
|
|
int
|
1994-05-26 05:23:31 +00:00
|
|
|
hasquota(fs, type, qfnamep)
|
2007-02-04 06:33:15 +00:00
|
|
|
struct fstab *fs;
|
1994-05-26 05:23:31 +00:00
|
|
|
int type;
|
|
|
|
char **qfnamep;
|
|
|
|
{
|
2007-02-04 06:33:15 +00:00
|
|
|
char *opt;
|
1997-10-13 11:05:07 +00:00
|
|
|
char *cp;
|
2007-02-04 06:33:15 +00:00
|
|
|
struct statfs sfb;
|
1994-05-26 05:23:31 +00:00
|
|
|
static char initname, usrname[100], grpname[100];
|
|
|
|
static char buf[BUFSIZ];
|
|
|
|
|
|
|
|
if (!initname) {
|
2007-02-04 06:33:15 +00:00
|
|
|
(void)snprintf(usrname, sizeof(usrname), "%s%s",
|
|
|
|
qfextension[USRQUOTA], qfname);
|
|
|
|
(void)snprintf(grpname, sizeof(grpname), "%s%s",
|
|
|
|
qfextension[GRPQUOTA], qfname);
|
1994-05-26 05:23:31 +00:00
|
|
|
initname = 1;
|
|
|
|
}
|
|
|
|
strcpy(buf, fs->fs_mntops);
|
|
|
|
for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
|
1997-10-13 11:05:07 +00:00
|
|
|
if ((cp = index(opt, '=')))
|
1994-05-26 05:23:31 +00:00
|
|
|
*cp++ = '\0';
|
|
|
|
if (type == USRQUOTA && strcmp(opt, usrname) == 0)
|
|
|
|
break;
|
|
|
|
if (type == GRPQUOTA && strcmp(opt, grpname) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!opt)
|
|
|
|
return (0);
|
2007-02-04 06:33:15 +00:00
|
|
|
if (cp)
|
1994-05-26 05:23:31 +00:00
|
|
|
*qfnamep = cp;
|
2007-02-04 06:33:15 +00:00
|
|
|
else {
|
|
|
|
(void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file,
|
|
|
|
qfname, qfextension[type]);
|
|
|
|
*qfnamep = buf;
|
|
|
|
}
|
|
|
|
if (statfs(fs->fs_file, &sfb) != 0) {
|
|
|
|
warn("cannot statfs mount point %s", fs->fs_file);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (strcmp(fs->fs_file, sfb.f_mntonname)) {
|
|
|
|
warnx("%s not mounted for %s quotas", fs->fs_file,
|
|
|
|
type == USRQUOTA ? "user" : "group");
|
|
|
|
return (0);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routines to manage the file usage table.
|
|
|
|
*
|
|
|
|
* Lookup an id of a specific type.
|
|
|
|
*/
|
|
|
|
struct fileusage *
|
|
|
|
lookup(id, type)
|
|
|
|
u_long id;
|
|
|
|
int type;
|
|
|
|
{
|
|
|
|
register struct fileusage *fup;
|
|
|
|
|
|
|
|
for (fup = fuhead[type][id & (FUHASH-1)]; fup != 0; fup = fup->fu_next)
|
|
|
|
if (fup->fu_id == id)
|
|
|
|
return (fup);
|
|
|
|
return ((struct fileusage *)0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a new file usage id if it does not already exist.
|
|
|
|
*/
|
|
|
|
struct fileusage *
|
|
|
|
addid(id, type, name)
|
|
|
|
u_long id;
|
|
|
|
int type;
|
|
|
|
char *name;
|
|
|
|
{
|
|
|
|
struct fileusage *fup, **fhp;
|
|
|
|
int len;
|
|
|
|
|
1997-10-13 11:05:07 +00:00
|
|
|
if ((fup = lookup(id, type)))
|
1994-05-26 05:23:31 +00:00
|
|
|
return (fup);
|
|
|
|
if (name)
|
|
|
|
len = strlen(name);
|
|
|
|
else
|
|
|
|
len = 10;
|
1997-10-13 11:05:07 +00:00
|
|
|
if ((fup = (struct fileusage *)calloc(1, sizeof(*fup) + len)) == NULL)
|
|
|
|
errx(1, "out of memory for fileusage structures");
|
1994-05-26 05:23:31 +00:00
|
|
|
fhp = &fuhead[type][id & (FUHASH - 1)];
|
|
|
|
fup->fu_next = *fhp;
|
|
|
|
*fhp = fup;
|
|
|
|
fup->fu_id = id;
|
|
|
|
if (id > highid[type])
|
|
|
|
highid[type] = id;
|
|
|
|
if (name) {
|
|
|
|
bcopy(name, fup->fu_name, len + 1);
|
|
|
|
} else {
|
1995-05-07 08:13:37 +00:00
|
|
|
sprintf(fup->fu_name, "%lu", id);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
return (fup);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the grace period and return a printable string for it.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
timeprt(seconds)
|
|
|
|
time_t seconds;
|
|
|
|
{
|
|
|
|
time_t hours, minutes;
|
|
|
|
static char buf[20];
|
|
|
|
static time_t now;
|
|
|
|
|
|
|
|
if (now == 0)
|
|
|
|
time(&now);
|
2001-12-10 06:25:35 +00:00
|
|
|
if (now > seconds) {
|
|
|
|
strlcpy(buf, "none", sizeof (buf));
|
|
|
|
return (buf);
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
seconds -= now;
|
|
|
|
minutes = (seconds + 30) / 60;
|
|
|
|
hours = (minutes + 30) / 60;
|
|
|
|
if (hours >= 36) {
|
2001-12-10 06:25:35 +00:00
|
|
|
sprintf(buf, "%lddays", (long)(hours + 12) / 24);
|
1994-05-26 05:23:31 +00:00
|
|
|
return (buf);
|
|
|
|
}
|
|
|
|
if (minutes >= 60) {
|
2001-12-10 06:25:35 +00:00
|
|
|
sprintf(buf, "%2ld:%ld", (long)minutes / 60,
|
|
|
|
(long)minutes % 60);
|
1994-05-26 05:23:31 +00:00
|
|
|
return (buf);
|
|
|
|
}
|
2001-12-10 06:25:35 +00:00
|
|
|
sprintf(buf, "%2ld", (long)minutes);
|
1994-05-26 05:23:31 +00:00
|
|
|
return (buf);
|
|
|
|
}
|