]>
Commit | Line | Data |
---|---|---|
d9eab45c | 1 | /* |
93d9f139 | 2 | * Copyright (c) 2001-2003 Silicon Graphics, Inc. All Rights Reserved. |
d9eab45c SL |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it would be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 | * | |
12 | * Further, this software is distributed without any warranty that it is | |
13 | * free of the rightful claim of any third person regarding infringement | |
14 | * or the like. Any license provided herein, whether implied or | |
15 | * otherwise, applies only to this software file. Patent licenses, if | |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | ||
33 | #include <libxfs.h> | |
d9eab45c SL |
34 | |
35 | char *progname; | |
36 | ||
37 | static void | |
38 | usage(void) | |
39 | { | |
9440d84d | 40 | fprintf(stderr, _( |
d9eab45c SL |
41 | "Usage: %s [options] mountpoint\n\n\ |
42 | Options:\n\ | |
dfc130f3 RC |
43 | -f freeze filesystem access\n\ |
44 | -u unfreeze filesystem access\n"), | |
d9eab45c SL |
45 | progname); |
46 | exit(2); | |
47 | } | |
48 | ||
49 | int | |
50 | main(int argc, char **argv) | |
51 | { | |
52 | int c; /* current option character */ | |
53 | int ffd; /* mount point file descriptor */ | |
54 | int fflag, uflag; | |
55 | int level; | |
93d9f139 | 56 | char *fname; |
d9eab45c SL |
57 | |
58 | fflag = uflag = 0; | |
59 | progname = basename(argv[0]); | |
9440d84d NS |
60 | setlocale(LC_ALL, ""); |
61 | bindtextdomain(PACKAGE, LOCALEDIR); | |
62 | textdomain(PACKAGE); | |
63 | ||
d9eab45c SL |
64 | while ((c = getopt(argc, argv, "fu")) != EOF) { |
65 | switch (c) { | |
66 | case 'f': | |
67 | fflag = 1; | |
68 | break; | |
69 | case 'u': | |
70 | uflag = 1; | |
71 | break; | |
72 | case '?': | |
73 | default: | |
74 | usage(); | |
75 | } | |
76 | } | |
77 | if (argc - optind != 1) | |
78 | usage(); | |
79 | if ((fflag + uflag) != 1) | |
80 | usage(); | |
81 | ||
93d9f139 NS |
82 | fname = argv[optind]; |
83 | ffd = open(fname, O_RDONLY); | |
d9eab45c | 84 | if (ffd < 0) { |
93d9f139 | 85 | perror(fname); |
d9eab45c SL |
86 | return 1; |
87 | } | |
dfc130f3 | 88 | |
93d9f139 | 89 | if (!platform_test_xfs_fd(ffd)) { |
9440d84d NS |
90 | fprintf(stderr, _("%s: specified file " |
91 | "[\"%s\"] is not on an XFS filesystem\n"), | |
92 | progname, argv[optind]); | |
d9eab45c SL |
93 | exit(1); |
94 | } | |
95 | ||
96 | if (fflag) { | |
97 | level = 1; | |
93d9f139 | 98 | if (xfsctl(fname, ffd, XFS_IOC_FREEZE, &level) < 0) { |
9440d84d NS |
99 | fprintf(stderr, _("%s: cannot freeze filesystem" |
100 | " mounted at %s: %s\n"), | |
d9eab45c SL |
101 | progname, argv[optind], strerror(errno)); |
102 | exit(1); | |
103 | } | |
104 | } | |
105 | ||
106 | if (uflag) { | |
93d9f139 | 107 | if (xfsctl(fname, ffd, XFS_IOC_THAW, &level) < 0) { |
9440d84d NS |
108 | fprintf(stderr, _("%s: cannot unfreeze filesystem" |
109 | " mounted at %s: %s\n"), | |
d9eab45c SL |
110 | progname, argv[optind], strerror(errno)); |
111 | exit(1); | |
112 | } | |
113 | } | |
114 | ||
115 | close(ffd); | |
dcc73dfb | 116 | return 0; |
d9eab45c | 117 | } |