~ubuntu-branches/ubuntu/utopic/xfsprogs/utopic-proposed

« back to all changes in this revision

Viewing changes to quota/report.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2009-05-06 11:29:18 UTC
  • mfrom: (8.1.1 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090506112918-uzoyzcp90rtr8td7
Tags: 3.0.2
New bugfix release

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
static void
46
46
report_help(void)
47
47
{
48
 
        report_cmd.args = _("[-bir] [-gpu] [-ahnt] [-f file]");
 
48
        report_cmd.args = _("[-bir] [-gpu] [-ahntLNU] [-f file]");
49
49
        report_cmd.oneline = _("report filesystem quota information");
50
50
        printf(_(
51
51
"\n"
61
61
" -n -- skip identifier-to-name translations, just report IDs\n"
62
62
" -N -- suppress the header from the output\n"
63
63
" -t -- terse output format, hides rows which are all zero\n"
 
64
" -L -- lower ID bound to report on\n"
 
65
" -U -- upper ID bound to report on\n"
64
66
" -g -- report group usage and quota information\n"
65
67
" -p -- report project usage and quota information\n"
66
68
" -u -- report user usage and quota information\n"
79
81
{
80
82
        fs_disk_quota_t d;
81
83
 
82
 
        if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0)
 
84
        if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0) {
 
85
                if (errno != ENOENT && errno != ENOSYS)
 
86
                        perror("XFS_GETQUOTA");
83
87
                return;
 
88
        }
84
89
        if (!d.d_blk_softlimit && !d.d_blk_hardlimit &&
85
90
            !d.d_ino_softlimit && !d.d_ino_hardlimit &&
86
91
            !d.d_rtb_softlimit && !d.d_rtb_hardlimit)
115
120
        uint            id;
116
121
 
117
122
        if ((mount = fs_table_lookup(dir, FS_MOUNT_POINT)) == NULL) {
 
123
                exitcode = 1;
118
124
                fprintf(stderr, "%s: cannot find mount point %s\n",
119
125
                        progname, dir);
120
126
                return;
121
127
        }
122
128
 
123
129
        if (upper) {
124
 
                for (id = lower; id < upper; id++)
 
130
                for (id = lower; id <= upper; id++)
125
131
                        dump_file(fp, id, type, mount->fs_name);
126
132
                return;
127
133
        }
295
301
        uint            qflags;
296
302
        int             count;
297
303
 
298
 
        if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0)
 
304
        if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0) {
 
305
                if (errno != ENOENT && errno != ENOSYS)
 
306
                        perror("XFS_GETQUOTA");
299
307
                return 0;
 
308
        }
300
309
 
301
310
        if (flags & TERSE_FLAG) {
302
311
                count = 0;
395
404
        uint            id;
396
405
 
397
406
        if (upper) {    /* identifier range specified */
398
 
                for (id = lower; id < upper; id++) {
 
407
                for (id = lower; id <= upper; id++) {
399
408
                        snprintf(n, sizeof(n)-1, "#%u", id);
400
409
                        if (report_mount(fp, id, n,
401
410
                                        form, XFS_USER_QUOTA, mount, flags))
433
442
        uint            id;
434
443
 
435
444
        if (upper) {    /* identifier range specified */
436
 
                for (id = lower; id < upper; id++) {
 
445
                for (id = lower; id <= upper; id++) {
437
446
                        snprintf(n, sizeof(n)-1, "#%u", id);
438
447
                        if (report_mount(fp, id, n,
439
448
                                        form, XFS_GROUP_QUOTA, mount, flags))
470
479
        uint            id;
471
480
 
472
481
        if (upper) {    /* identifier range specified */
473
 
                for (id = lower; id < upper; id++) {
 
482
                for (id = lower; id <= upper; id++) {
474
483
                        snprintf(n, sizeof(n)-1, "#%u", id);
475
484
                        if (report_mount(fp, id, n,
476
485
                                        form, XFS_PROJ_QUOTA, mount, flags))
511
520
        if (type & XFS_USER_QUOTA) {
512
521
                fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
513
522
                while ((mount = fs_cursor_next_entry(&cursor))) {
514
 
                        xfsquotactl(XFS_QSYNC, mount->fs_name,
515
 
                                                XFS_USER_QUOTA, 0, NULL);
 
523
                        if (xfsquotactl(XFS_QSYNC, mount->fs_name,
 
524
                                                XFS_USER_QUOTA, 0, NULL) < 0
 
525
                                        && errno != ENOENT && errno != ENOSYS)
 
526
                                perror("XFS_QSYNC user quota");
516
527
                        report_user_mount(fp, form, mount,
517
528
                                                lower, upper, flags);
518
529
                }
520
531
        if (type & XFS_GROUP_QUOTA) {
521
532
                fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
522
533
                while ((mount = fs_cursor_next_entry(&cursor))) {
523
 
                        xfsquotactl(XFS_QSYNC, mount->fs_name,
524
 
                                                XFS_GROUP_QUOTA, 0, NULL);
 
534
                        if (xfsquotactl(XFS_QSYNC, mount->fs_name,
 
535
                                                XFS_GROUP_QUOTA, 0, NULL) < 0
 
536
                                        && errno != ENOENT && errno != ENOSYS)
 
537
                                perror("XFS_QSYNC group quota");
525
538
                        report_group_mount(fp, form, mount,
526
539
                                                lower, upper, flags);
527
540
                }
529
542
        if (type & XFS_PROJ_QUOTA) {
530
543
                fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
531
544
                while ((mount = fs_cursor_next_entry(&cursor))) {
532
 
                        xfsquotactl(XFS_QSYNC, mount->fs_name,
533
 
                                                XFS_PROJ_QUOTA, 0, NULL);
 
545
                        if (xfsquotactl(XFS_QSYNC, mount->fs_name,
 
546
                                                XFS_PROJ_QUOTA, 0, NULL) < 0
 
547
                                        && errno != ENOENT && errno != ENOSYS)
 
548
                                perror("XFS_QSYNC proj quota");
534
549
                        report_project_mount(fp, form, mount,
535
550
                                                lower, upper, flags);
536
551
                }