+ return 0;
+}
+
+#define BSLIMIT (1 << 0)
+#define BHLIMIT (1 << 1)
+#define ISLIMIT (1 << 2)
+#define IHLIMIT (1 << 3)
+
+int lfs_setquota(int argc, char **argv)
+{
+ int c, rc;
+ struct if_quotactl qctl;
+ char *mnt, *obd_type = (char *)qctl.obd_type;
+ struct obd_dqblk *dqb = &qctl.qc_dqblk;
+ struct option long_opts[] = {
+ {"user", required_argument, 0, 'u'},
+ {"group", required_argument, 0, 'g'},
+ {"block-softlimit", required_argument, 0, 'b'},
+ {"block-hardlimit", required_argument, 0, 'B'},
+ {"inode-softlimit", required_argument, 0, 'i'},
+ {"inode-hardlimit", required_argument, 0, 'I'},
+ {0, 0, 0, 0}
+ };
+ unsigned limit_mask = 0;
+
+ if (has_times_option(argc, argv))
+ return lfs_setquota_times(argc, argv);
+
+ memset(&qctl, 0, sizeof(qctl));
+ qctl.qc_cmd = LUSTRE_Q_SETQUOTA;
+ qctl.qc_type = UGQUOTA; /* UGQUOTA makes no sense for setquota,
+ * so it can be used as a marker that qc_type
+ * isn't reinitialized from command line */
+
+ optind = 0;
+ while ((c = getopt_long(argc, argv, "u:g:b:B:i:I:", long_opts, NULL)) != -1) {
+ switch (c) {
+ case 'u':
+ case 'g':
+ if (qctl.qc_type != UGQUOTA) {
+ fprintf(stderr, "error: -u and -g can't be used"
+ " more than once\n");
+ return CMD_HELP;
+ }
+ qctl.qc_type = (c == 'u') ? USRQUOTA : GRPQUOTA;
+ rc = name2id(&qctl.qc_id, optarg,
+ (qctl.qc_type == USRQUOTA) ? USER : GROUP);
+ if (rc) {
+ fprintf(stderr, "error: unknown id %s\n",
+ optarg);
+ return CMD_HELP;
+ }
+ break;
+ case 'b':
+ ARG2ULL(dqb->dqb_bsoftlimit, optarg, 1024);
+ dqb->dqb_bsoftlimit >>= 10;
+ limit_mask |= BSLIMIT;
+ break;
+ case 'B':
+ ARG2ULL(dqb->dqb_bhardlimit, optarg, 1024);
+ dqb->dqb_bhardlimit >>= 10;
+ limit_mask |= BHLIMIT;
+ break;
+ case 'i':
+ ARG2ULL(dqb->dqb_isoftlimit, optarg, 1);
+ limit_mask |= ISLIMIT;
+ break;
+ case 'I':
+ ARG2ULL(dqb->dqb_ihardlimit, optarg, 1);
+ limit_mask |= IHLIMIT;
+ break;
+ default: /* getopt prints error message for us when opterr != 0 */