db07609875
segfaults from bnc#710486 due to unchecked usage of return value of open_ctree() [fixed compilation warnings] - pull upstream, replace existing patches, spec update - update 'restore' utility - lzo support - tools may now take earlies superblock when opening the fs - other fixes - pull integration-20111030 branch - mkfs: force mkfs if desired - other fixes - add btrfs-dump-super to mkinitrd - other fixes - skip non-existent devices or without media - documentation updates - scrubbing single device - graceful error handling when opening fs fails - updated mkinitrd script to scan devices before mount (bnc#727383) OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=115
109 lines
2.9 KiB
Diff
109 lines
2.9 KiB
Diff
From 8456dc84b0c7548ca4f83c4e58e8e9dd443b7686 Mon Sep 17 00:00:00 2001
|
|
From: Goffredo Baroncelli <kreijack@inwind.it>
|
|
Date: Mon, 3 Jan 2011 19:51:46 +0100
|
|
Subject: [PATCH 03/35] Add the --force option.
|
|
|
|
Add the --force option to not check if a device is already mounted.
|
|
---
|
|
mkfs.c | 46 ++++++++++++++++++++++++++++------------------
|
|
1 files changed, 28 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/mkfs.c b/mkfs.c
|
|
index e3ced19..be236d0 100644
|
|
--- a/mkfs.c
|
|
+++ b/mkfs.c
|
|
@@ -303,6 +303,7 @@ static void print_usage(void)
|
|
fprintf(stderr, "\t -A --alloc-start the offset to start the FS\n");
|
|
fprintf(stderr, "\t -b --byte-count total number of bytes in the FS\n");
|
|
fprintf(stderr, "\t -d --data data profile, raid0, raid1, raid10 or single\n");
|
|
+ fprintf(stderr, "\t -f --force don't check if a device is already mounted\n");
|
|
fprintf(stderr, "\t -l --leafsize size of btree leaves\n");
|
|
fprintf(stderr, "\t -L --label set a label\n");
|
|
fprintf(stderr, "\t -m --metadata metadata profile, values like data profile\n");
|
|
@@ -368,6 +369,7 @@ static struct option long_options[] = {
|
|
{ "data", 1, NULL, 'd' },
|
|
{ "version", 0, NULL, 'V' },
|
|
{ "rootdir", 1, NULL, 'r' },
|
|
+ { "force", 0, NULL, 'f' },
|
|
{ 0, 0, 0, 0}
|
|
};
|
|
|
|
@@ -1191,10 +1193,11 @@ int main(int ac, char **av)
|
|
u64 size_of_data = 0;
|
|
u64 source_dir_size = 0;
|
|
char *pretty_buf;
|
|
+ int force=0;
|
|
|
|
while(1) {
|
|
int c;
|
|
- c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:r:VM", long_options,
|
|
+ c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:r:VMf", long_options,
|
|
&option_index);
|
|
if (c < 0)
|
|
break;
|
|
@@ -1240,6 +1243,8 @@ int main(int ac, char **av)
|
|
case 'r':
|
|
source_dir = optarg;
|
|
source_dir_set = 1;
|
|
+ case 'f':
|
|
+ force=1;
|
|
break;
|
|
default:
|
|
print_usage();
|
|
@@ -1263,14 +1268,17 @@ int main(int ac, char **av)
|
|
|
|
if (source_dir == 0) {
|
|
file = av[optind++];
|
|
- ret = check_mounted(file);
|
|
- if (ret < 0) {
|
|
- fprintf(stderr, "error checking %s mount status\n", file);
|
|
- exit(1);
|
|
- }
|
|
- if (ret == 1) {
|
|
- fprintf(stderr, "%s is mounted\n", file);
|
|
- exit(1);
|
|
+ if(!force){
|
|
+ ret = check_mounted(file);
|
|
+ if (ret < 0) {
|
|
+ fprintf(stderr,
|
|
+ "error checking %s mount status\n", file);
|
|
+ exit(1);
|
|
+ }
|
|
+ if (ret == 1) {
|
|
+ fprintf(stderr, "%s is mounted\n", file);
|
|
+ exit(1);
|
|
+ }
|
|
}
|
|
ac--;
|
|
fd = open(file, O_RDWR);
|
|
@@ -1353,15 +1361,17 @@ int main(int ac, char **av)
|
|
int old_mixed = mixed;
|
|
|
|
file = av[optind++];
|
|
- ret = check_mounted(file);
|
|
- if (ret < 0) {
|
|
- fprintf(stderr, "error checking %s mount status\n",
|
|
- file);
|
|
- exit(1);
|
|
- }
|
|
- if (ret == 1) {
|
|
- fprintf(stderr, "%s is mounted\n", file);
|
|
- exit(1);
|
|
+ if(!force){
|
|
+ ret = check_mounted(file);
|
|
+ if (ret < 0) {
|
|
+ fprintf(stderr, "error checking %s"
|
|
+ " mount status\n",file);
|
|
+ exit(1);
|
|
+ }
|
|
+ if (ret == 1) {
|
|
+ fprintf(stderr, "%s is mounted\n", file);
|
|
+ exit(1);
|
|
+ }
|
|
}
|
|
fd = open(file, O_RDWR);
|
|
if (fd < 0) {
|
|
--
|
|
1.7.6.233.gd79bc
|
|
|