]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/init.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
11 #include "err_protos.h"
17 #include "libfrog/crc32cselftest.h"
18 #include <sys/resource.h>
23 pthread_key_create(&dblkmap_key
, NULL
);
24 pthread_key_create(&ablkmap_key
, NULL
);
33 if (getrlimit(RLIMIT_FSIZE
, &rl
) == -1) {
35 fprintf(stderr
, _("getrlimit(RLIMIT_FSIZE) failed!\n"));
38 if (rl
.rlim_cur
!= RLIM_INFINITY
) {
39 rl
.rlim_max
= rl
.rlim_cur
= RLIM_INFINITY
;
40 if (setrlimit(RLIMIT_FSIZE
, &rl
) == -1) {
43 _("setrlimit failed - current: %lld, max: %lld\n"),
44 (unsigned long long)rl
.rlim_cur
,
45 (unsigned long long)rl
.rlim_max
);
52 xfs_init(libxfs_init_t
*args
)
54 memset(args
, 0, sizeof(libxfs_init_t
));
58 args
->dname
= fs_name
;
62 args
->volname
= fs_name
;
66 if (log_spec
) { /* External log specified */
67 args
->logname
= log_name
;
68 args
->lisfile
= (isa_file
?1:0);
69 /* XXX assume data file also means log file */
70 /* REVISIT: Need to do fs sanity / log validity checking */
73 if (rt_spec
) { /* RT device specified */
74 args
->rtname
= rt_name
;
75 args
->risfile
= (isa_file
?1:0);
76 /* XXX assume data file also means rt file */
79 args
->usebuflock
= do_prefetch
;
81 args
->isdirect
= LIBXFS_DIRECT
;
83 args
->isreadonly
= (LIBXFS_ISREADONLY
| LIBXFS_ISINACTIVE
);
85 args
->isreadonly
= (LIBXFS_ISINACTIVE
| LIBXFS_DANGEROUSLY
);
87 args
->isreadonly
= LIBXFS_EXCLUSIVELY
;
89 if (!libxfs_init(args
)) {
90 /* would -d be an option? */
91 if (!no_modify
&& !dangerously
) {
92 args
->isreadonly
= (LIBXFS_ISINACTIVE
|
94 if (libxfs_init(args
))
96 _("Unmount or use the dangerous (-d) option to repair a read-only mounted filesystem\n"));
98 do_error(_("couldn't initialize XFS library\n"));
105 if (crc32c_test(CRC32CTEST_QUIET
) != 0)
107 _("crc32c self-test failed, will not examine filesystem.\n"));