diff options
-rw-r--r-- | Changelog | 4 | ||||
-rw-r--r-- | bylabel.c | 8 | ||||
-rw-r--r-- | common.c | 4 | ||||
-rw-r--r-- | common.h | 4 | ||||
-rw-r--r-- | quot.c | 2 | ||||
-rw-r--r-- | quotacheck.c | 6 | ||||
-rw-r--r-- | quotacheck_v2.c | 6 | ||||
-rw-r--r-- | quotaio.c | 2 | ||||
-rw-r--r-- | quotaio_v2.c | 2 | ||||
-rw-r--r-- | quotaon.c | 10 | ||||
-rw-r--r-- | quotasys.c | 34 | ||||
-rw-r--r-- | quotasys.h | 5 | ||||
-rw-r--r-- | repquota.c | 4 |
13 files changed, 57 insertions, 34 deletions
@@ -1,4 +1,8 @@ Changes in quota-tools from 3.14 to 3.15 +* fixed XFS handling to work with loopback mounted devices (Jan Kara) +* fixed mountpoints scanning to make XFS -x delete command work (Jan Kara) +* fixes of signed vs unsigned int issues (Jan Kara) +* fixed a format string bug in reporting of raw grace times in repquota (Jan Kara) * added repquota(8) option for better parsable output (Jan Kara) * fixed error handling in edquota(8) when creating tmp file (Jan Kara) @@ -90,7 +90,7 @@ static int get_label_uuid(const char *device, char **label, char *uuid) memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid)); namesize = sizeof(e2sb.s_volume_name); *label = smalloc(namesize + 1); - sstrncpy(*label, e2sb.s_volume_name, namesize); + sstrncpy(*label, (char *)e2sb.s_volume_name, namesize); rv = 0; } else if (lseek(fd, 0, SEEK_SET) == 0 @@ -100,7 +100,7 @@ static int get_label_uuid(const char *device, char **label, char *uuid) memcpy(uuid, xfsb.s_uuid, sizeof(xfsb.s_uuid)); namesize = sizeof(xfsb.s_fsname); *label = smalloc(namesize + 1); - sstrncpy(*label, xfsb.s_fsname, namesize); + sstrncpy(*label, (char *)xfsb.s_fsname, namesize); rv = 0; } else if (lseek(fd, 65536, SEEK_SET) == 65536 @@ -109,7 +109,7 @@ static int get_label_uuid(const char *device, char **label, char *uuid) memcpy(uuid, reisersb.s_uuid, sizeof(reisersb.s_uuid)); namesize = sizeof(reisersb.s_volume_name); *label = smalloc(namesize + 1); - sstrncpy(*label, reisersb.s_volume_name, namesize); + sstrncpy(*label, (char *)reisersb.s_volume_name, namesize); rv = 0; } close(fd); @@ -245,7 +245,7 @@ static char *get_spec_by_uuid(const char *s) uuid[i] = ((fromhex(s[0]) << 4) | fromhex(s[1])); s += 2; } - return get_spec_by_x(UUID, uuid); + return get_spec_by_x(UUID, (char *)uuid); bad_uuid: errstr(_("Found an invalid UUID: %s\n"), s); @@ -94,13 +94,13 @@ void *srealloc(void *ptr, size_t size) return ret; } -void sstrncpy(char *d, const char *s, int len) +void sstrncpy(char *d, const char *s, size_t len) { strncpy(d, s, len); d[len - 1] = 0; } -void sstrncat(char *d, const char *s, int len) +void sstrncat(char *d, const char *s, size_t len) { strncat(d, s, len); d[len - 1] = 0; @@ -35,10 +35,10 @@ void *smalloc(size_t); void *srealloc(void *, size_t); /* Safe strncpy - always finishes string */ -void sstrncpy(char *, const char *, int); +void sstrncpy(char *, const char *, size_t); /* Safe strncat - always finishes string */ -void sstrncat(char *, const char *, int); +void sstrncat(char *, const char *, size_t); /* Safe version of strdup() */ char *sstrdup(const char *s); @@ -339,7 +339,7 @@ static void acctXFS(xfs_bstat_t *p) static void checkXFS(const char *file, char *fsdir) { xfs_fsop_bulkreq_t bulkreq; - __s64 last = 0; + __u64 last = 0; __s32 count; int i; int sts; diff --git a/quotacheck.c b/quotacheck.c index d2b487d..8b46819 100644 --- a/quotacheck.c +++ b/quotacheck.c @@ -8,7 +8,7 @@ * New quota format implementation - Jan Kara <jack@suse.cz> - Sponsored by SuSE CR */ -#ident "$Id: quotacheck.c,v 1.52 2007/01/06 13:08:01 marcovw Exp $" +#ident "$Id: quotacheck.c,v 1.53 2007/02/21 13:51:25 jkar8572 Exp $" #include <dirent.h> #include <stdio.h> @@ -1039,11 +1039,11 @@ static void check_all(void) continue; } cfmt = fmt; - if (uwant && hasquota(mnt, USRQUOTA)) + if (uwant && hasquota(mnt, USRQUOTA, 0)) ucheck = 1; else ucheck = 0; - if (gwant && hasquota(mnt, GRPQUOTA)) + if (gwant && hasquota(mnt, GRPQUOTA, 0)) gcheck = 1; else gcheck = 0; diff --git a/quotacheck_v2.c b/quotacheck_v2.c index fe607a1..f567a2a 100644 --- a/quotacheck_v2.c +++ b/quotacheck_v2.c @@ -223,7 +223,7 @@ static void check_read_blk(int fd, uint blk, dqbuf_t buf) } } -static int check_tree_ref(uint blk, uint ref, uint blocks, int check_use, uint * corrupted, +static int check_tree_ref(uint blk, uint ref, uint blocks, int check_use, int * corrupted, uint * lblk) { if (check_blkref(ref, blocks) < 0) { @@ -239,7 +239,7 @@ static int check_tree_ref(uint blk, uint ref, uint blocks, int check_use, uint * } /* Check block with structures */ -static int check_data_blk(int fd, uint blk, int type, uint blocks, uint * corrupted, uint * lblk) +static int check_data_blk(int fd, uint blk, int type, uint blocks, int * corrupted, uint * lblk) { dqbuf_t buf = getdqbuf(); struct v2_disk_dqdbheader *head = (struct v2_disk_dqdbheader *)buf; @@ -265,7 +265,7 @@ static int check_data_blk(int fd, uint blk, int type, uint blocks, uint * corrup } /* Check one tree block */ -static int check_tree_blk(int fd, uint blk, int depth, int type, uint blocks, uint * corrupted, +static int check_tree_blk(int fd, uint blk, int depth, int type, uint blocks, int * corrupted, uint * lblk) { dqbuf_t buf = getdqbuf(); @@ -42,7 +42,7 @@ struct quota_handle *init_io(struct mntent *mnt, int type, int fmt, int flags) struct quota_handle *h = smalloc(sizeof(struct quota_handle)); const char *mnt_fsname = NULL; - if (!hasquota(mnt, type)) + if (!hasquota(mnt, type, 0)) goto out_handle; if (!(mnt_fsname = get_device_name(mnt->mnt_fsname))) goto out_handle; diff --git a/quotaio_v2.c b/quotaio_v2.c index bf4aed0..39d0517 100644 --- a/quotaio_v2.c +++ b/quotaio_v2.c @@ -471,7 +471,7 @@ static int do_insert_tree(struct quota_handle *h, struct dquot *dquot, uint * tr /* Wrapper for inserting quota structure into tree */ static inline void dq_insert_tree(struct quota_handle *h, struct dquot *dquot) { - int tmp = V2_DQTREEOFF; + uint tmp = V2_DQTREEOFF; if (do_insert_tree(h, dquot, &tmp, 0) < 0) die(2, _("Cannot write quota (id %u): %s\n"), (uint) dquot->dq_id, strerror(errno)); @@ -34,7 +34,7 @@ #ident "$Copyright: (c) 1980, 1990 Regents of the University of California $" #ident "$Copyright: All rights reserved. $" -#ident "$Id: quotaon.c,v 1.22 2006/05/13 01:05:24 jkar8572 Exp $" +#ident "$Id: quotaon.c,v 1.23 2007/02/21 13:51:25 jkar8572 Exp $" /* * Turn quota on/off for a filesystem. @@ -174,7 +174,7 @@ static int newstate(struct mntent *mnt, int type, char *extra) ret = xfs_newstate(mnt, type, extra, sflags); } else { - if (!hasquota(mnt, type)) + if (!hasquota(mnt, type, 0)) return 0; usefmt = get_qf_name(mnt, type, fmt == -1 ? kernel_formats : (1 << fmt), NF_FORMAT, &extra); if (usefmt < 0) { @@ -301,7 +301,7 @@ int v1_newstate(struct mntent *mnt, int type, char *file, int flags) return 1; if ((flags & STATEFLAG_OFF) && hasmntopt(mnt, MNTOPT_RSQUASH)) errs += quotarsquashonoff(dev, type, flags); - if (hasquota(mnt, type)) + if (hasquota(mnt, type, 0)) errs += quotaonoff((char *)dev, mnt->mnt_dir, file, type, QF_VFSOLD, flags); if ((flags & STATEFLAG_ON) && hasmntopt(mnt, MNTOPT_RSQUASH)) errs += quotarsquashonoff(dev, type, flags); @@ -319,7 +319,7 @@ int v2_newstate(struct mntent *mnt, int type, char *file, int flags) if (!dev) return 1; - if (hasquota(mnt, type)) + if (hasquota(mnt, type, 0)) errs = quotaonoff((char *)dev, mnt->mnt_dir, file, type, QF_VFSV0, flags); free((char *)dev); return errs; @@ -346,7 +346,7 @@ int main(int argc, char **argv) else if (!kernel_formats) errstr(_("Warning: No quota format detected in the kernel.\n")); - if (init_mounts_scan(mntcnt, mntpoints, 0) < 0) + if (init_mounts_scan(mntcnt, mntpoints, MS_XFS_DISABLED) < 0) return 1; while ((mnt = get_next_mount())) { if (nfs_fstype(mnt->mnt_type)) { @@ -366,10 +366,10 @@ void space2str(qsize_t space, char *buf, int format) if (format) for (i = 3; i > 0; i--) if (space >= (1LL << (QUOTABLOCK_BITS*i))*100) { - sprintf(buf, "%Lu%c", (space+(1 << (QUOTABLOCK_BITS*i))-1) >> (QUOTABLOCK_BITS*i), suffix[i]); + sprintf(buf, "%Lu%c", (unsigned long long)(space+(1 << (QUOTABLOCK_BITS*i))-1) >> (QUOTABLOCK_BITS*i), suffix[i]); return; } - sprintf(buf, "%Lu", space); + sprintf(buf, "%Lu", (unsigned long long)space); } /* @@ -393,15 +393,31 @@ void number2str(unsigned long long num, char *buf, int format) /* * Check for XFS filesystem with quota accounting enabled */ -static int hasxfsquota(struct mntent *mnt, int type) +static int hasxfsquota(struct mntent *mnt, int type, int flags) { int ret = 0; u_int16_t sbflags; struct xfs_mem_dqinfo info; - const char *dev = get_device_name(mnt->mnt_fsname); + const char *dev; + char *opt, *endopt; + if (flags & MS_XFS_DISABLED) + return 1; + + dev = get_device_name(mnt->mnt_fsname); if (!dev) - return ret; + return 0; + /* Loopback mounted device with a loopback device in the arguments? */ + if ((opt = hasmntopt(mnt, MNTOPT_LOOP)) && (opt = strchr(opt, '='))) { + free((char *)dev); + endopt = strchr(opt+1, ','); + if (!endopt) + dev = strdup(opt+1); + else + dev = strndup(opt+1, endopt-opt-1); + if (!dev) + return 0; + } memset(&info, 0, sizeof(struct xfs_mem_dqinfo)); if (!quotactl(QCMD(Q_XFS_GETQSTAT, type), dev, 0, (void *)&info)) { @@ -444,13 +460,13 @@ char *hasmntoptarg(struct mntent *mnt, char *opt) /* * Check to see if a particular quota is to be enabled (filesystem mounted with proper option) */ -int hasquota(struct mntent *mnt, int type) +int hasquota(struct mntent *mnt, int type, int flags) { if (!correct_fstype(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA)) return 0; if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) - return hasxfsquota(mnt, type); + return hasxfsquota(mnt, type, flags); if (nfs_fstype(mnt->mnt_type)) /* NFS always has quota or better there is no good way how to detect it */ return 1; @@ -873,7 +889,7 @@ static int cache_mnt_table(int flags) /* Further we are not interested in mountpoints without quotas and we don't want to touch them */ - if (!hasquota(mnt, USRQUOTA) && !hasquota(mnt, GRPQUOTA)) { + if (!hasquota(mnt, USRQUOTA, flags) && !hasquota(mnt, GRPQUOTA, flags)) { free((char *)devname); continue; } @@ -1124,7 +1140,7 @@ restart: break; } if (i == mnt_entries_cnt) { - errstr(_("Mountpoint (or device) %s not found.\n"), sd->sd_name); + errstr(_("Mountpoint (or device) %s not found or has no quota enabled.\n"), sd->sd_name); goto restart; } *pos = i; @@ -96,7 +96,8 @@ void space2str(qsize_t, char *, int); void number2str(unsigned long long, char *, int); /* Check to see if particular quota is to be enabled */ -int hasquota(struct mntent *mnt, int type); +/* Recognizes MS_XFS_DISABLED flag */ +int hasquota(struct mntent *mnt, int type, int flags); /* Flags for get_qf_name() */ #define NF_EXIST 1 /* Check whether file exists */ @@ -130,6 +131,8 @@ int kern_quota_on(const char *dev, int type, int fmt); #define MS_NO_AUTOFS 0x02 /* Ignore autofs mountpoints */ #define MS_QUIET 0x04 /* Be quiet with error reporting */ #define MS_LOCALONLY 0x08 /* Ignore nfs mountpoints */ +#define MS_XFS_DISABLED 0x10 /* Return also XFS mountpoints with quota disabled */ + /* Initialize mountpoints scan */ int init_mounts_scan(int dcnt, char **dirs, int flags); @@ -181,7 +181,7 @@ static void print(struct dquot *dquot, char *name) pname[PRINTNAMELEN] = 0; if (entry->dqb_bsoftlimit && toqb(entry->dqb_curspace) >= entry->dqb_bsoftlimit) if (flags & FL_RAWGRACE) - sprintf(time, "%s", entry->dqb_btime); + sprintf(time, "%Lu", (unsigned long long)entry->dqb_btime); else difftime2str(entry->dqb_btime, time); else @@ -198,7 +198,7 @@ static void print(struct dquot *dquot, char *name) numbuf[0], numbuf[1], numbuf[2], time); if (entry->dqb_isoftlimit && entry->dqb_curinodes >= entry->dqb_isoftlimit) if (flags & FL_RAWGRACE) - sprintf(time, "%s", entry->dqb_itime); + sprintf(time, "%Lu", (unsigned long long)entry->dqb_itime); else difftime2str(entry->dqb_itime, time); else |