+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2005 Silicon Graphics, Inc.
* All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <pwd.h>
#include <grp.h>
#include <ctype.h>
-#include "xfs/input.h"
-#include "xfs/command.h"
+#include "input.h"
+#include "command.h"
#include "init.h"
#include "quota.h"
static void
set_limits(
- __uint32_t id,
+ uint32_t id,
uint type,
uint mask,
char *dev,
- __uint64_t *bsoft,
- __uint64_t *bhard,
- __uint64_t *isoft,
- __uint64_t *ihard,
- __uint64_t *rtbsoft,
- __uint64_t *rtbhard)
+ uint64_t *bsoft,
+ uint64_t *bhard,
+ uint64_t *isoft,
+ uint64_t *ihard,
+ uint64_t *rtbsoft,
+ uint64_t *rtbhard)
{
fs_disk_quota_t d;
char *name,
uint type,
uint mask,
- __uint64_t *bsoft,
- __uint64_t *bhard,
- __uint64_t *isoft,
- __uint64_t *ihard,
- __uint64_t *rtbsoft,
- __uint64_t *rtbhard)
+ uint64_t *bsoft,
+ uint64_t *bhard,
+ uint64_t *isoft,
+ uint64_t *ihard,
+ uint64_t *rtbsoft,
+ uint64_t *rtbhard)
{
uid_t uid = uid_from_string(name);
char *name,
uint type,
uint mask,
- __uint64_t *bsoft,
- __uint64_t *bhard,
- __uint64_t *isoft,
- __uint64_t *ihard,
- __uint64_t *rtbsoft,
- __uint64_t *rtbhard)
+ uint64_t *bsoft,
+ uint64_t *bhard,
+ uint64_t *isoft,
+ uint64_t *ihard,
+ uint64_t *rtbsoft,
+ uint64_t *rtbhard)
{
gid_t gid = gid_from_string(name);
char *name,
uint type,
uint mask,
- __uint64_t *bsoft,
- __uint64_t *bhard,
- __uint64_t *isoft,
- __uint64_t *ihard,
- __uint64_t *rtbsoft,
- __uint64_t *rtbhard)
+ uint64_t *bsoft,
+ uint64_t *bhard,
+ uint64_t *isoft,
+ uint64_t *ihard,
+ uint64_t *rtbsoft,
+ uint64_t *rtbhard)
{
prid_t prid = prid_from_string(name);
int length,
uint blocksize,
uint sectorsize,
- __uint64_t *value)
+ uint64_t *value)
{
long long v;
char *s = string;
progname, s);
return 0;
}
- *value = (__uint64_t)v >> 9; /* syscalls use basic blocks */
+ *value = (uint64_t)v >> 9; /* syscalls use basic blocks */
if (v > 0 && *value == 0)
fprintf(stderr, _("%s: Warning: `%s' in quota blocks is 0 (unlimited).\n"), progname, s);
return 1;
char *string,
const char *prefix,
int length,
- __uint64_t *value)
+ uint64_t *value)
{
char *sp, *s = string;
char **argv)
{
char *name;
- __uint64_t bsoft, bhard, isoft, ihard, rtbsoft, rtbhard;
+ uint64_t bsoft, bhard, isoft, ihard, rtbsoft, rtbhard;
int c, type = 0, mask = 0, flags = 0;
uint bsize, ssize, endoptions;
flags |= DEFAULTS_FLAG;
break;
case 'g':
- type = XFS_GROUP_QUOTA;
+ type |= XFS_GROUP_QUOTA;
break;
case 'p':
- type = XFS_PROJ_QUOTA;
+ type |= XFS_PROJ_QUOTA;
break;
case 'u':
- type = XFS_USER_QUOTA;
+ type |= XFS_USER_QUOTA;
break;
default:
return command_usage(&limit_cmd);
name = (flags & DEFAULTS_FLAG) ? "0" : argv[optind++];
- if (!type)
+ if (!type) {
type = XFS_USER_QUOTA;
+ } else if (type != XFS_GROUP_QUOTA &&
+ type != XFS_PROJ_QUOTA &&
+ type != XFS_USER_QUOTA) {
+ return command_usage(&limit_cmd);
+ }
switch (type) {
case XFS_USER_QUOTA:
uint type)
{
char buffer[512];
- char devbuffer[512];
- char *dev = NULL;
+ char dev[512];
uint mask;
int cnt;
- __uint32_t id;
- __uint64_t bsoft, bhard, isoft, ihard, rtbsoft, rtbhard;
+ uint32_t id;
+ uint64_t bsoft, bhard, isoft, ihard, rtbsoft, rtbhard;
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
if (strncmp("fs = ", buffer, 5) == 0) {
- dev = strncpy(devbuffer, buffer+5, sizeof(devbuffer));
+ /*
+ * Copy the device name to dev, strip off the trailing
+ * newline, and move on to the next line.
+ */
+ strncpy(dev, buffer + 5, sizeof(dev) - 1);
dev[strlen(dev) - 1] = '\0';
continue;
}
fname = optarg;
break;
case 'g':
- type = XFS_GROUP_QUOTA;
+ type |= XFS_GROUP_QUOTA;
break;
case 'p':
- type = XFS_PROJ_QUOTA;
+ type |= XFS_PROJ_QUOTA;
break;
case 'u':
- type = XFS_USER_QUOTA;
+ type |= XFS_USER_QUOTA;
break;
default:
return command_usage(&restore_cmd);
if (argc < optind)
return command_usage(&restore_cmd);
- if (!type)
+ if (!type) {
type = XFS_USER_QUOTA;
+ } else if (type != XFS_GROUP_QUOTA &&
+ type != XFS_PROJ_QUOTA &&
+ type != XFS_USER_QUOTA) {
+ return command_usage(&restore_cmd);
+ }
if (fname) {
if ((fp = fopen(fname, "r")) == NULL) {
mask |= FS_DQ_RTBTIMER;
break;
case 'g':
- type = XFS_GROUP_QUOTA;
+ type |= XFS_GROUP_QUOTA;
break;
case 'p':
- type = XFS_PROJ_QUOTA;
+ type |= XFS_PROJ_QUOTA;
break;
case 'u':
- type = XFS_USER_QUOTA;
+ type |= XFS_USER_QUOTA;
break;
default:
return command_usage(&timer_cmd);
if (!mask)
mask = FS_DQ_TIMER_MASK;
- if (!type)
+ if (!type) {
type = XFS_USER_QUOTA;
+ } else if (type != XFS_GROUP_QUOTA &&
+ type != XFS_PROJ_QUOTA &&
+ type != XFS_USER_QUOTA) {
+ return command_usage(&timer_cmd);
+ }
set_timer(type, mask, fs_path->fs_name, value);
return 0;
static void
set_warnings(
- __uint32_t id,
+ uint32_t id,
uint type,
uint mask,
char *dev,
mask |= FS_DQ_RTBWARNS;
break;
case 'g':
- type = XFS_GROUP_QUOTA;
+ type |= XFS_GROUP_QUOTA;
break;
case 'p':
- type = XFS_PROJ_QUOTA;
+ type |= XFS_PROJ_QUOTA;
break;
case 'u':
- type = XFS_USER_QUOTA;
+ type |= XFS_USER_QUOTA;
break;
default:
return command_usage(&warn_cmd);
if (!mask)
mask = FS_DQ_WARNS_MASK;
- if (!type)
+ if (!type) {
type = XFS_USER_QUOTA;
+ } else if (type != XFS_GROUP_QUOTA &&
+ type != XFS_PROJ_QUOTA &&
+ type != XFS_USER_QUOTA) {
+ return command_usage(&warn_cmd);
+ }
switch (type) {
case XFS_USER_QUOTA:
limit_cmd.argmin = 2;
limit_cmd.argmax = -1;
limit_cmd.args = \
- _("[-gpu] bsoft|bhard|isoft|ihard|rtbsoft|rtbhard=N -d|id|name");
+ _("[-g|-p|-u] bsoft|bhard|isoft|ihard|rtbsoft|rtbhard=N -d|id|name");
limit_cmd.oneline = _("modify quota limits");
limit_cmd.help = limit_help;
+ limit_cmd.flags = CMD_FLAG_FOREIGN_OK;
restore_cmd.name = "restore";
restore_cmd.cfunc = restore_f;
restore_cmd.argmin = 0;
restore_cmd.argmax = -1;
- restore_cmd.args = _("[-gpu] [-f file]");
+ restore_cmd.args = _("[-g|-p|-u] [-f file]");
restore_cmd.oneline = _("restore quota limits from a backup file");
+ restore_cmd.flags = CMD_FLAG_FOREIGN_OK;
timer_cmd.name = "timer";
timer_cmd.cfunc = timer_f;
timer_cmd.argmin = 2;
timer_cmd.argmax = -1;
- timer_cmd.args = _("[-bir] [-gpu] value -d|id|name");
- timer_cmd.oneline = _("get/set quota enforcement timeouts");
+ timer_cmd.args = _("[-bir] [-g|-p|-u] value");
+ timer_cmd.oneline = _("set quota enforcement timeouts");
timer_cmd.help = timer_help;
+ timer_cmd.flags = CMD_FLAG_FOREIGN_OK;
warn_cmd.name = "warn";
warn_cmd.cfunc = warn_f;
warn_cmd.argmin = 2;
warn_cmd.argmax = -1;
- warn_cmd.args = _("[-bir] [-gpu] value -d|id|name");
+ warn_cmd.args = _("[-bir] [-g|-p|-u] value -d|id|name");
warn_cmd.oneline = _("get/set enforcement warning counter");
warn_cmd.help = warn_help;