1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker * util.c --- helper functions used by tune2fs and mke2fs
3*6a54128fSAndroid Build Coastguard Worker *
4*6a54128fSAndroid Build Coastguard Worker * Copyright 1995, 1996, 1997, 1998, 1999, 2000 by Theodore Ts'o.
5*6a54128fSAndroid Build Coastguard Worker *
6*6a54128fSAndroid Build Coastguard Worker * %Begin-Header%
7*6a54128fSAndroid Build Coastguard Worker * This file may be redistributed under the terms of the GNU Public
8*6a54128fSAndroid Build Coastguard Worker * License.
9*6a54128fSAndroid Build Coastguard Worker * %End-Header%
10*6a54128fSAndroid Build Coastguard Worker */
11*6a54128fSAndroid Build Coastguard Worker
12*6a54128fSAndroid Build Coastguard Worker #ifndef _LARGEFILE_SOURCE
13*6a54128fSAndroid Build Coastguard Worker #define _LARGEFILE_SOURCE
14*6a54128fSAndroid Build Coastguard Worker #endif
15*6a54128fSAndroid Build Coastguard Worker #ifndef _LARGEFILE64_SOURCE
16*6a54128fSAndroid Build Coastguard Worker #define _LARGEFILE64_SOURCE
17*6a54128fSAndroid Build Coastguard Worker #endif
18*6a54128fSAndroid Build Coastguard Worker
19*6a54128fSAndroid Build Coastguard Worker #ifdef _WIN32
20*6a54128fSAndroid Build Coastguard Worker #define _POSIX
21*6a54128fSAndroid Build Coastguard Worker #define __USE_MINGW_ALARM
22*6a54128fSAndroid Build Coastguard Worker #endif
23*6a54128fSAndroid Build Coastguard Worker
24*6a54128fSAndroid Build Coastguard Worker #include "config.h"
25*6a54128fSAndroid Build Coastguard Worker #include <fcntl.h>
26*6a54128fSAndroid Build Coastguard Worker #include <setjmp.h>
27*6a54128fSAndroid Build Coastguard Worker #include <signal.h>
28*6a54128fSAndroid Build Coastguard Worker #include <stdio.h>
29*6a54128fSAndroid Build Coastguard Worker #include <string.h>
30*6a54128fSAndroid Build Coastguard Worker #ifdef HAVE_ERRNO_H
31*6a54128fSAndroid Build Coastguard Worker #include <errno.h>
32*6a54128fSAndroid Build Coastguard Worker #endif
33*6a54128fSAndroid Build Coastguard Worker #if HAVE_UNISTD_H
34*6a54128fSAndroid Build Coastguard Worker #include <unistd.h>
35*6a54128fSAndroid Build Coastguard Worker #endif
36*6a54128fSAndroid Build Coastguard Worker #ifdef HAVE_LINUX_MAJOR_H
37*6a54128fSAndroid Build Coastguard Worker #include <linux/major.h>
38*6a54128fSAndroid Build Coastguard Worker #endif
39*6a54128fSAndroid Build Coastguard Worker #include <sys/types.h>
40*6a54128fSAndroid Build Coastguard Worker #ifdef HAVE_SYS_STAT_H
41*6a54128fSAndroid Build Coastguard Worker #include <sys/stat.h>
42*6a54128fSAndroid Build Coastguard Worker #endif
43*6a54128fSAndroid Build Coastguard Worker #ifdef HAVE_UNISTD_H
44*6a54128fSAndroid Build Coastguard Worker #include <unistd.h>
45*6a54128fSAndroid Build Coastguard Worker #endif
46*6a54128fSAndroid Build Coastguard Worker #include <time.h>
47*6a54128fSAndroid Build Coastguard Worker
48*6a54128fSAndroid Build Coastguard Worker #include "et/com_err.h"
49*6a54128fSAndroid Build Coastguard Worker #include "e2p/e2p.h"
50*6a54128fSAndroid Build Coastguard Worker #include "ext2fs/ext2_fs.h"
51*6a54128fSAndroid Build Coastguard Worker #include "ext2fs/ext2fs.h"
52*6a54128fSAndroid Build Coastguard Worker #include "support/nls-enable.h"
53*6a54128fSAndroid Build Coastguard Worker #include "support/devname.h"
54*6a54128fSAndroid Build Coastguard Worker #include "blkid/blkid.h"
55*6a54128fSAndroid Build Coastguard Worker #include "util.h"
56*6a54128fSAndroid Build Coastguard Worker
57*6a54128fSAndroid Build Coastguard Worker char *journal_location_string = NULL;
58*6a54128fSAndroid Build Coastguard Worker
59*6a54128fSAndroid Build Coastguard Worker #ifndef HAVE_STRCASECMP
strcasecmp(char * s1,char * s2)60*6a54128fSAndroid Build Coastguard Worker int strcasecmp (char *s1, char *s2)
61*6a54128fSAndroid Build Coastguard Worker {
62*6a54128fSAndroid Build Coastguard Worker while (*s1 && *s2) {
63*6a54128fSAndroid Build Coastguard Worker int ch1 = *s1++, ch2 = *s2++;
64*6a54128fSAndroid Build Coastguard Worker if (isupper (ch1))
65*6a54128fSAndroid Build Coastguard Worker ch1 = tolower (ch1);
66*6a54128fSAndroid Build Coastguard Worker if (isupper (ch2))
67*6a54128fSAndroid Build Coastguard Worker ch2 = tolower (ch2);
68*6a54128fSAndroid Build Coastguard Worker if (ch1 != ch2)
69*6a54128fSAndroid Build Coastguard Worker return ch1 - ch2;
70*6a54128fSAndroid Build Coastguard Worker }
71*6a54128fSAndroid Build Coastguard Worker return *s1 ? 1 : *s2 ? -1 : 0;
72*6a54128fSAndroid Build Coastguard Worker }
73*6a54128fSAndroid Build Coastguard Worker #endif
74*6a54128fSAndroid Build Coastguard Worker
75*6a54128fSAndroid Build Coastguard Worker /*
76*6a54128fSAndroid Build Coastguard Worker * Given argv[0], return the program name.
77*6a54128fSAndroid Build Coastguard Worker */
get_progname(char * argv_zero)78*6a54128fSAndroid Build Coastguard Worker char *get_progname(char *argv_zero)
79*6a54128fSAndroid Build Coastguard Worker {
80*6a54128fSAndroid Build Coastguard Worker char *cp;
81*6a54128fSAndroid Build Coastguard Worker
82*6a54128fSAndroid Build Coastguard Worker cp = strrchr(argv_zero, '/');
83*6a54128fSAndroid Build Coastguard Worker if (!cp )
84*6a54128fSAndroid Build Coastguard Worker return argv_zero;
85*6a54128fSAndroid Build Coastguard Worker else
86*6a54128fSAndroid Build Coastguard Worker return cp+1;
87*6a54128fSAndroid Build Coastguard Worker }
88*6a54128fSAndroid Build Coastguard Worker
89*6a54128fSAndroid Build Coastguard Worker static jmp_buf alarm_env;
90*6a54128fSAndroid Build Coastguard Worker
alarm_signal(int signal EXT2FS_ATTR ((unused)))91*6a54128fSAndroid Build Coastguard Worker static void alarm_signal(int signal EXT2FS_ATTR((unused)))
92*6a54128fSAndroid Build Coastguard Worker {
93*6a54128fSAndroid Build Coastguard Worker longjmp(alarm_env, 1);
94*6a54128fSAndroid Build Coastguard Worker }
95*6a54128fSAndroid Build Coastguard Worker
proceed_question(int delay)96*6a54128fSAndroid Build Coastguard Worker void proceed_question(int delay)
97*6a54128fSAndroid Build Coastguard Worker {
98*6a54128fSAndroid Build Coastguard Worker char buf[256];
99*6a54128fSAndroid Build Coastguard Worker const char *short_yes = _("yY");
100*6a54128fSAndroid Build Coastguard Worker const char *english_yes = "yY";
101*6a54128fSAndroid Build Coastguard Worker
102*6a54128fSAndroid Build Coastguard Worker fflush(stdout);
103*6a54128fSAndroid Build Coastguard Worker fflush(stderr);
104*6a54128fSAndroid Build Coastguard Worker if (delay > 0) {
105*6a54128fSAndroid Build Coastguard Worker if (setjmp(alarm_env)) {
106*6a54128fSAndroid Build Coastguard Worker signal(SIGALRM, SIG_IGN);
107*6a54128fSAndroid Build Coastguard Worker printf("%s", _("<proceeding>\n"));
108*6a54128fSAndroid Build Coastguard Worker return;
109*6a54128fSAndroid Build Coastguard Worker }
110*6a54128fSAndroid Build Coastguard Worker signal(SIGALRM, alarm_signal);
111*6a54128fSAndroid Build Coastguard Worker printf(_("Proceed anyway (or wait %d seconds to proceed) ? (y,N) "),
112*6a54128fSAndroid Build Coastguard Worker delay);
113*6a54128fSAndroid Build Coastguard Worker alarm(delay);
114*6a54128fSAndroid Build Coastguard Worker } else
115*6a54128fSAndroid Build Coastguard Worker fputs(_("Proceed anyway? (y,N) "), stdout);
116*6a54128fSAndroid Build Coastguard Worker buf[0] = 0;
117*6a54128fSAndroid Build Coastguard Worker if (!fgets(buf, sizeof(buf), stdin) ||
118*6a54128fSAndroid Build Coastguard Worker strchr(_("nN"), buf[0]) ||
119*6a54128fSAndroid Build Coastguard Worker !(strchr(short_yes, buf[0]) ||
120*6a54128fSAndroid Build Coastguard Worker strchr(english_yes, buf[0]))) {
121*6a54128fSAndroid Build Coastguard Worker putc('\n', stdout);
122*6a54128fSAndroid Build Coastguard Worker exit(1);
123*6a54128fSAndroid Build Coastguard Worker }
124*6a54128fSAndroid Build Coastguard Worker signal(SIGALRM, SIG_IGN);
125*6a54128fSAndroid Build Coastguard Worker }
126*6a54128fSAndroid Build Coastguard Worker
check_mount(const char * device,int force,const char * type)127*6a54128fSAndroid Build Coastguard Worker void check_mount(const char *device, int force, const char *type)
128*6a54128fSAndroid Build Coastguard Worker {
129*6a54128fSAndroid Build Coastguard Worker errcode_t retval;
130*6a54128fSAndroid Build Coastguard Worker int mount_flags;
131*6a54128fSAndroid Build Coastguard Worker
132*6a54128fSAndroid Build Coastguard Worker retval = ext2fs_check_if_mounted(device, &mount_flags);
133*6a54128fSAndroid Build Coastguard Worker if (retval) {
134*6a54128fSAndroid Build Coastguard Worker com_err("ext2fs_check_if_mount", retval,
135*6a54128fSAndroid Build Coastguard Worker _("while determining whether %s is mounted."),
136*6a54128fSAndroid Build Coastguard Worker device);
137*6a54128fSAndroid Build Coastguard Worker return;
138*6a54128fSAndroid Build Coastguard Worker }
139*6a54128fSAndroid Build Coastguard Worker if (mount_flags & EXT2_MF_MOUNTED) {
140*6a54128fSAndroid Build Coastguard Worker fprintf(stderr, _("%s is mounted; "), device);
141*6a54128fSAndroid Build Coastguard Worker if (force >= 2) {
142*6a54128fSAndroid Build Coastguard Worker fputs(_("mke2fs forced anyway. Hope /etc/mtab is "
143*6a54128fSAndroid Build Coastguard Worker "incorrect.\n"), stderr);
144*6a54128fSAndroid Build Coastguard Worker return;
145*6a54128fSAndroid Build Coastguard Worker }
146*6a54128fSAndroid Build Coastguard Worker abort_mke2fs:
147*6a54128fSAndroid Build Coastguard Worker fprintf(stderr, _("will not make a %s here!\n"), type);
148*6a54128fSAndroid Build Coastguard Worker exit(1);
149*6a54128fSAndroid Build Coastguard Worker }
150*6a54128fSAndroid Build Coastguard Worker if (mount_flags & EXT2_MF_BUSY) {
151*6a54128fSAndroid Build Coastguard Worker fprintf(stderr, _("%s is apparently in use by the system; "),
152*6a54128fSAndroid Build Coastguard Worker device);
153*6a54128fSAndroid Build Coastguard Worker if (force >= 2) {
154*6a54128fSAndroid Build Coastguard Worker fputs(_("mke2fs forced anyway.\n"), stderr);
155*6a54128fSAndroid Build Coastguard Worker return;
156*6a54128fSAndroid Build Coastguard Worker }
157*6a54128fSAndroid Build Coastguard Worker goto abort_mke2fs;
158*6a54128fSAndroid Build Coastguard Worker }
159*6a54128fSAndroid Build Coastguard Worker }
160*6a54128fSAndroid Build Coastguard Worker
parse_journal_opts(const char * opts)161*6a54128fSAndroid Build Coastguard Worker void parse_journal_opts(const char *opts)
162*6a54128fSAndroid Build Coastguard Worker {
163*6a54128fSAndroid Build Coastguard Worker char *buf, *token, *next, *p, *arg;
164*6a54128fSAndroid Build Coastguard Worker int len;
165*6a54128fSAndroid Build Coastguard Worker int journal_usage = 0;
166*6a54128fSAndroid Build Coastguard Worker
167*6a54128fSAndroid Build Coastguard Worker len = strlen(opts);
168*6a54128fSAndroid Build Coastguard Worker buf = malloc(len+1);
169*6a54128fSAndroid Build Coastguard Worker if (!buf) {
170*6a54128fSAndroid Build Coastguard Worker fputs(_("Couldn't allocate memory to parse journal "
171*6a54128fSAndroid Build Coastguard Worker "options!\n"), stderr);
172*6a54128fSAndroid Build Coastguard Worker exit(1);
173*6a54128fSAndroid Build Coastguard Worker }
174*6a54128fSAndroid Build Coastguard Worker strcpy(buf, opts);
175*6a54128fSAndroid Build Coastguard Worker for (token = buf; token && *token; token = next) {
176*6a54128fSAndroid Build Coastguard Worker p = strchr(token, ',');
177*6a54128fSAndroid Build Coastguard Worker next = 0;
178*6a54128fSAndroid Build Coastguard Worker if (p) {
179*6a54128fSAndroid Build Coastguard Worker *p = 0;
180*6a54128fSAndroid Build Coastguard Worker next = p+1;
181*6a54128fSAndroid Build Coastguard Worker }
182*6a54128fSAndroid Build Coastguard Worker arg = strchr(token, '=');
183*6a54128fSAndroid Build Coastguard Worker if (arg) {
184*6a54128fSAndroid Build Coastguard Worker *arg = 0;
185*6a54128fSAndroid Build Coastguard Worker arg++;
186*6a54128fSAndroid Build Coastguard Worker }
187*6a54128fSAndroid Build Coastguard Worker #if 0
188*6a54128fSAndroid Build Coastguard Worker printf("Journal option=%s, argument=%s\n", token,
189*6a54128fSAndroid Build Coastguard Worker arg ? arg : "NONE");
190*6a54128fSAndroid Build Coastguard Worker #endif
191*6a54128fSAndroid Build Coastguard Worker if (strcmp(token, "device") == 0) {
192*6a54128fSAndroid Build Coastguard Worker journal_device = get_devname(NULL, arg, NULL);
193*6a54128fSAndroid Build Coastguard Worker if (!journal_device) {
194*6a54128fSAndroid Build Coastguard Worker if (arg)
195*6a54128fSAndroid Build Coastguard Worker fprintf(stderr, _("\nCould not find "
196*6a54128fSAndroid Build Coastguard Worker "journal device matching %s\n"),
197*6a54128fSAndroid Build Coastguard Worker arg);
198*6a54128fSAndroid Build Coastguard Worker journal_usage++;
199*6a54128fSAndroid Build Coastguard Worker continue;
200*6a54128fSAndroid Build Coastguard Worker }
201*6a54128fSAndroid Build Coastguard Worker } else if (strcmp(token, "size") == 0) {
202*6a54128fSAndroid Build Coastguard Worker if (!arg) {
203*6a54128fSAndroid Build Coastguard Worker journal_usage++;
204*6a54128fSAndroid Build Coastguard Worker continue;
205*6a54128fSAndroid Build Coastguard Worker }
206*6a54128fSAndroid Build Coastguard Worker journal_size = strtoul(arg, &p, 0);
207*6a54128fSAndroid Build Coastguard Worker if (*p)
208*6a54128fSAndroid Build Coastguard Worker journal_usage++;
209*6a54128fSAndroid Build Coastguard Worker } else if (strcmp(token, "fast_commit_size") == 0) {
210*6a54128fSAndroid Build Coastguard Worker if (!arg) {
211*6a54128fSAndroid Build Coastguard Worker journal_usage++;
212*6a54128fSAndroid Build Coastguard Worker continue;
213*6a54128fSAndroid Build Coastguard Worker }
214*6a54128fSAndroid Build Coastguard Worker journal_fc_size = strtoul(arg, &p, 0);
215*6a54128fSAndroid Build Coastguard Worker if (*p)
216*6a54128fSAndroid Build Coastguard Worker journal_usage++;
217*6a54128fSAndroid Build Coastguard Worker } else if (!strcmp(token, "location")) {
218*6a54128fSAndroid Build Coastguard Worker if (!arg) {
219*6a54128fSAndroid Build Coastguard Worker journal_usage++;
220*6a54128fSAndroid Build Coastguard Worker continue;
221*6a54128fSAndroid Build Coastguard Worker }
222*6a54128fSAndroid Build Coastguard Worker journal_location_string = strdup(arg);
223*6a54128fSAndroid Build Coastguard Worker } else if (strcmp(token, "v1_superblock") == 0) {
224*6a54128fSAndroid Build Coastguard Worker journal_flags |= EXT2_MKJOURNAL_V1_SUPER;
225*6a54128fSAndroid Build Coastguard Worker continue;
226*6a54128fSAndroid Build Coastguard Worker } else
227*6a54128fSAndroid Build Coastguard Worker journal_usage++;
228*6a54128fSAndroid Build Coastguard Worker }
229*6a54128fSAndroid Build Coastguard Worker if (journal_usage) {
230*6a54128fSAndroid Build Coastguard Worker fputs(_("\nBad journal options specified.\n\n"
231*6a54128fSAndroid Build Coastguard Worker "Journal options are separated by commas, "
232*6a54128fSAndroid Build Coastguard Worker "and may take an argument which\n"
233*6a54128fSAndroid Build Coastguard Worker "\tis set off by an equals ('=') sign.\n\n"
234*6a54128fSAndroid Build Coastguard Worker "Valid journal options are:\n"
235*6a54128fSAndroid Build Coastguard Worker "\tsize=<journal size in megabytes>\n"
236*6a54128fSAndroid Build Coastguard Worker "\tdevice=<journal device>\n"
237*6a54128fSAndroid Build Coastguard Worker "\tlocation=<journal location>\n\n"
238*6a54128fSAndroid Build Coastguard Worker "The journal size must be between "
239*6a54128fSAndroid Build Coastguard Worker "1024 and 10240000 filesystem blocks.\n\n"), stderr);
240*6a54128fSAndroid Build Coastguard Worker free(buf);
241*6a54128fSAndroid Build Coastguard Worker exit(1);
242*6a54128fSAndroid Build Coastguard Worker }
243*6a54128fSAndroid Build Coastguard Worker free(buf);
244*6a54128fSAndroid Build Coastguard Worker }
245*6a54128fSAndroid Build Coastguard Worker
jsize_to_blks(ext2_filsys fs,int size)246*6a54128fSAndroid Build Coastguard Worker static inline int jsize_to_blks(ext2_filsys fs, int size)
247*6a54128fSAndroid Build Coastguard Worker {
248*6a54128fSAndroid Build Coastguard Worker return (size * 1024) / (fs->blocksize / 1024);
249*6a54128fSAndroid Build Coastguard Worker }
250*6a54128fSAndroid Build Coastguard Worker
251*6a54128fSAndroid Build Coastguard Worker /* Fast commit size is in KBs */
fcsize_to_blks(ext2_filsys fs,int size)252*6a54128fSAndroid Build Coastguard Worker static inline int fcsize_to_blks(ext2_filsys fs, int size)
253*6a54128fSAndroid Build Coastguard Worker {
254*6a54128fSAndroid Build Coastguard Worker return (size * 1024) / (fs->blocksize);
255*6a54128fSAndroid Build Coastguard Worker }
256*6a54128fSAndroid Build Coastguard Worker
257*6a54128fSAndroid Build Coastguard Worker /*
258*6a54128fSAndroid Build Coastguard Worker * Determine the number of journal blocks to use, either via
259*6a54128fSAndroid Build Coastguard Worker * user-specified # of megabytes, or via some intelligently selected
260*6a54128fSAndroid Build Coastguard Worker * defaults.
261*6a54128fSAndroid Build Coastguard Worker *
262*6a54128fSAndroid Build Coastguard Worker * Find a reasonable journal file size (in blocks) given the number of blocks in
263*6a54128fSAndroid Build Coastguard Worker * the filesystem. For very small filesystems, it is not reasonable to have a
264*6a54128fSAndroid Build Coastguard Worker * journal that fills more than half of the filesystem.
265*6a54128fSAndroid Build Coastguard Worker */
figure_journal_size(struct ext2fs_journal_params * jparams,int requested_j_size,int requested_fc_size,ext2_filsys fs)266*6a54128fSAndroid Build Coastguard Worker void figure_journal_size(struct ext2fs_journal_params *jparams,
267*6a54128fSAndroid Build Coastguard Worker int requested_j_size, int requested_fc_size, ext2_filsys fs)
268*6a54128fSAndroid Build Coastguard Worker {
269*6a54128fSAndroid Build Coastguard Worker int total_blocks, ret;
270*6a54128fSAndroid Build Coastguard Worker
271*6a54128fSAndroid Build Coastguard Worker ret = ext2fs_get_journal_params(jparams, fs);
272*6a54128fSAndroid Build Coastguard Worker if (ret) {
273*6a54128fSAndroid Build Coastguard Worker fputs(_("\nFilesystem too small for a journal\n"), stderr);
274*6a54128fSAndroid Build Coastguard Worker return;
275*6a54128fSAndroid Build Coastguard Worker }
276*6a54128fSAndroid Build Coastguard Worker
277*6a54128fSAndroid Build Coastguard Worker if (requested_j_size > 0 ||
278*6a54128fSAndroid Build Coastguard Worker (ext2fs_has_feature_fast_commit(fs->super) && requested_fc_size > 0)) {
279*6a54128fSAndroid Build Coastguard Worker if (requested_j_size > 0)
280*6a54128fSAndroid Build Coastguard Worker jparams->num_journal_blocks =
281*6a54128fSAndroid Build Coastguard Worker jsize_to_blks(fs, requested_j_size);
282*6a54128fSAndroid Build Coastguard Worker if (ext2fs_has_feature_fast_commit(fs->super) &&
283*6a54128fSAndroid Build Coastguard Worker requested_fc_size > 0)
284*6a54128fSAndroid Build Coastguard Worker jparams->num_fc_blocks =
285*6a54128fSAndroid Build Coastguard Worker fcsize_to_blks(fs, requested_fc_size);
286*6a54128fSAndroid Build Coastguard Worker else if (!ext2fs_has_feature_fast_commit(fs->super))
287*6a54128fSAndroid Build Coastguard Worker jparams->num_fc_blocks = 0;
288*6a54128fSAndroid Build Coastguard Worker total_blocks = jparams->num_journal_blocks + jparams->num_fc_blocks;
289*6a54128fSAndroid Build Coastguard Worker if (total_blocks < 1024 || total_blocks > 10240000) {
290*6a54128fSAndroid Build Coastguard Worker fprintf(stderr, _("\nThe total requested journal "
291*6a54128fSAndroid Build Coastguard Worker "size is %d blocks; it must be\n"
292*6a54128fSAndroid Build Coastguard Worker "between 1024 and 10240000 blocks. "
293*6a54128fSAndroid Build Coastguard Worker "Aborting.\n"),
294*6a54128fSAndroid Build Coastguard Worker total_blocks);
295*6a54128fSAndroid Build Coastguard Worker exit(1);
296*6a54128fSAndroid Build Coastguard Worker }
297*6a54128fSAndroid Build Coastguard Worker if ((unsigned int) total_blocks > ext2fs_free_blocks_count(fs->super) / 2) {
298*6a54128fSAndroid Build Coastguard Worker fputs(_("\nTotal journal size too big for filesystem.\n"),
299*6a54128fSAndroid Build Coastguard Worker stderr);
300*6a54128fSAndroid Build Coastguard Worker exit(1);
301*6a54128fSAndroid Build Coastguard Worker }
302*6a54128fSAndroid Build Coastguard Worker }
303*6a54128fSAndroid Build Coastguard Worker }
304*6a54128fSAndroid Build Coastguard Worker
print_check_message(int mnt,unsigned int check)305*6a54128fSAndroid Build Coastguard Worker void print_check_message(int mnt, unsigned int check)
306*6a54128fSAndroid Build Coastguard Worker {
307*6a54128fSAndroid Build Coastguard Worker if (mnt < 0)
308*6a54128fSAndroid Build Coastguard Worker mnt = 0;
309*6a54128fSAndroid Build Coastguard Worker if (!mnt && !check)
310*6a54128fSAndroid Build Coastguard Worker return;
311*6a54128fSAndroid Build Coastguard Worker printf(_("This filesystem will be automatically "
312*6a54128fSAndroid Build Coastguard Worker "checked every %d mounts or\n"
313*6a54128fSAndroid Build Coastguard Worker "%g days, whichever comes first. "
314*6a54128fSAndroid Build Coastguard Worker "Use tune2fs -c or -i to override.\n"),
315*6a54128fSAndroid Build Coastguard Worker mnt, ((double) check) / (3600 * 24));
316*6a54128fSAndroid Build Coastguard Worker }
317*6a54128fSAndroid Build Coastguard Worker
dump_mmp_msg(struct mmp_struct * mmp,const char * msg)318*6a54128fSAndroid Build Coastguard Worker void dump_mmp_msg(struct mmp_struct *mmp, const char *msg)
319*6a54128fSAndroid Build Coastguard Worker {
320*6a54128fSAndroid Build Coastguard Worker
321*6a54128fSAndroid Build Coastguard Worker if (msg)
322*6a54128fSAndroid Build Coastguard Worker printf("MMP check failed: %s\n", msg);
323*6a54128fSAndroid Build Coastguard Worker if (mmp) {
324*6a54128fSAndroid Build Coastguard Worker time_t t = mmp->mmp_time;
325*6a54128fSAndroid Build Coastguard Worker
326*6a54128fSAndroid Build Coastguard Worker printf("MMP error info: node: %.*s, device: %.*s, updated: %s",
327*6a54128fSAndroid Build Coastguard Worker EXT2_LEN_STR(mmp->mmp_nodename),
328*6a54128fSAndroid Build Coastguard Worker EXT2_LEN_STR(mmp->mmp_bdevname), ctime(&t));
329*6a54128fSAndroid Build Coastguard Worker }
330*6a54128fSAndroid Build Coastguard Worker }
331