/*
- * Copyright (c) 2001 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (c) 2001-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
*/
#include <libxfs.h>
-#include <sys/ioctl.h>
char *progname;
static void
usage(void)
{
- fprintf(stderr,
+ fprintf(stderr, _(
"Usage: %s [options] mountpoint\n\n\
Options:\n\
- -f freeze filesystem access\n\
- -u unfreeze filesystem access\n",
+ -f freeze filesystem access\n\
+ -u unfreeze filesystem access\n"),
progname);
exit(2);
}
int ffd; /* mount point file descriptor */
int fflag, uflag;
int level;
- struct statfs buf;
+ char *fname;
fflag = uflag = 0;
progname = basename(argv[0]);
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
while ((c = getopt(argc, argv, "fu")) != EOF) {
switch (c) {
case 'f':
if ((fflag + uflag) != 1)
usage();
- ffd = open(argv[optind], O_RDONLY);
+ fname = argv[optind];
+ ffd = open(fname, O_RDONLY);
if (ffd < 0) {
- perror(argv[optind]);
+ perror(fname);
return 1;
}
- fstatfs(ffd, &buf);
- if (statfstype(&buf) != XFS_SUPER_MAGIC) {
- fprintf(stderr,
- "%s: specified file is not on an XFS filesystem\n",
- progname);
+
+ if (!platform_test_xfs_fd(ffd)) {
+ fprintf(stderr, _("%s: specified file "
+ "[\"%s\"] is not on an XFS filesystem\n"),
+ progname, argv[optind]);
exit(1);
}
if (fflag) {
level = 1;
- if (ioctl(ffd, XFS_IOC_FREEZE, &level) < 0) {
- fprintf(stderr, "%s: cannot freeze filesystem"
- " mounted at %s: %s\n",
+ if (xfsctl(fname, ffd, XFS_IOC_FREEZE, &level) < 0) {
+ fprintf(stderr, _("%s: cannot freeze filesystem"
+ " mounted at %s: %s\n"),
progname, argv[optind], strerror(errno));
exit(1);
}
}
if (uflag) {
- if (ioctl(ffd, XFS_IOC_THAW, &level) < 0) {
- fprintf(stderr, "%s: cannot unfreeze filesystem"
- " mounted at %s: %s\n",
+ if (xfsctl(fname, ffd, XFS_IOC_THAW, &level) < 0) {
+ fprintf(stderr, _("%s: cannot unfreeze filesystem"
+ " mounted at %s: %s\n"),
progname, argv[optind], strerror(errno));
exit(1);
}