+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2004-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 <xfs/xfs.h>
-#include <xfs/command.h>
-#include <xfs/input.h>
+#include "command.h"
+#include "input.h"
#include <sys/mman.h>
#include "init.h"
#include "io.h"
static cmdinfo_t mincore_cmd;
-int
+static int
mincore_f(
int argc,
char **argv)
{
- off64_t offset;
+ off64_t offset, llength;
size_t length;
size_t blocksize, sectsize;
void *start;
argv[1]);
return 0;
}
- length = cvtnum(blocksize, sectsize, argv[2]);
- if (length < 0) {
+ llength = cvtnum(blocksize, sectsize, argv[2]);
+ if (llength < 0) {
printf(_("non-numeric length argument -- %s\n"),
argv[2]);
return 0;
- }
+ } else if (llength > (size_t)llength) {
+ printf(_("length argument too large -- %lld\n"),
+ (long long)llength);
+ return 0;
+ } else
+ length = (size_t)llength;
} else {
return command_usage(&mincore_cmd);
}
void
mincore_init(void)
{
- mincore_cmd.name = _("mincore");
- mincore_cmd.altname = _("mi");
+ mincore_cmd.name = "mincore";
+ mincore_cmd.altname = "mi";
mincore_cmd.cfunc = mincore_f;
mincore_cmd.argmin = 0;
mincore_cmd.argmax = 2;