* mkfs.btrfs doesn't work inside loopback mounted chroot jails: error checking /dev/sda3 mount status
@ 2011-02-04 9:38 Bernhard Rosenkraenzer
2011-02-04 9:51 ` Felix Blanke
0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Rosenkraenzer @ 2011-02-04 9:38 UTC (permalink / raw)
To: linux-btrfs
[-- Attachment #1: Type: text/plain, Size: 746 bytes --]
Hi,
mkfs.btrfs aborts unconditionally with "error checking [whatever] mount status" under some circumstances.
I'm running into it when using a live CD that boots from a minimal CD image, then does
mount -o loop -t squashfs /squashfs.img /mnt/realsystem
chroot /mnt/realsystem
[stuff you actually want to do here]
strace shows mkfs.btrfs aborting after trying to
lstat("/squashfs.img", 0x7fff2c712c90) = -1 ENOENT (No such file or directory)
[obviously, it can't access /squashfs.img after chroot]
I'm attaching a "fix" that allows circumventing the problem with a --force switch, patch is relative to "next" branch in git.
I'm also adding this patch to the Ark Linux package of btrfs-progs unless someone screams very loudly. ;)
ttyl
bero
[-- Attachment #2: 0001-Add-a-force-option.patch --]
[-- Type: application/octet-stream, Size: 2896 bytes --]
From 910fbac9acc7f1ba0a1641cfa85e8ed0b96e94cb Mon Sep 17 00:00:00 2001
From: Bernhard Rosenkraenzer <bero@arklinux.ch>
Date: Fri, 4 Feb 2011 10:31:14 +0059
Subject: [PATCH] Add a --force option
---
mkfs.c | 47 ++++++++++++++++++++++++++++-------------------
1 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/mkfs.c b/mkfs.c
index 2e99b95..2fa8be8 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -271,6 +271,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 bypass check if the 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");
@@ -332,6 +333,7 @@ static struct option long_options[] = {
{ "sectorsize", 1, NULL, 's' },
{ "data", 1, NULL, 'd' },
{ "version", 0, NULL, 'V' },
+ { "force", 0, NULL, 'f' },
{ 0, 0, 0, 0}
};
@@ -358,10 +360,11 @@ int main(int ac, char **av)
int first_fd;
int ret;
int i;
+ int force = 0;
while(1) {
int c;
- c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:V", long_options,
+ c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:Vf", long_options,
&option_index);
if (c < 0)
break;
@@ -401,6 +404,9 @@ int main(int ac, char **av)
case 'V':
print_version();
break;
+ case 'f':
+ force = 1;
+ break;
default:
print_usage();
}
@@ -423,13 +429,15 @@ int main(int ac, char **av)
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) {
+ 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);
@@ -479,16 +487,18 @@ int main(int ac, char **av)
zero_end = 1;
while(ac-- > 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);
+ }
+ }
fd = open(file, O_RDWR);
if (fd < 0) {
fprintf(stderr, "unable to open %s\n", file);
@@ -534,4 +544,3 @@ raid_groups:
free(label);
return 0;
}
-
--
1.7.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: mkfs.btrfs doesn't work inside loopback mounted chroot jails: error checking /dev/sda3 mount status
2011-02-04 9:38 mkfs.btrfs doesn't work inside loopback mounted chroot jails: error checking /dev/sda3 mount status Bernhard Rosenkraenzer
@ 2011-02-04 9:51 ` Felix Blanke
0 siblings, 0 replies; 2+ messages in thread
From: Felix Blanke @ 2011-02-04 9:51 UTC (permalink / raw)
To: Bernhard Rosenkraenzer; +Cc: linux-btrfs
Hi,
you should search the mailinglist before you write patches :)
That problem is known and a patch is available:
https://patchwork.kernel.org/patch/449001/
But it isn't in the btrfs-progs git yet.
Regards,
Felix
Am Fri, 04 Feb 2011 10:38:25 +0100
schrieb "Bernhard Rosenkraenzer" <bero@arklinux.ch>:
> Hi,
> mkfs.btrfs aborts unconditionally with "error checking [whatever]
> mount status" under some circumstances.
>
> I'm running into it when using a live CD that boots from a minimal CD
> image, then does
>
> mount -o loop -t squashfs /squashfs.img /mnt/realsystem
> chroot /mnt/realsystem
> [stuff you actually want to do here]
>
> strace shows mkfs.btrfs aborting after trying to
>
> lstat("/squashfs.img", 0x7fff2c712c90) = -1 ENOENT (No such file or
> directory)
>
> [obviously, it can't access /squashfs.img after chroot]
>
>
> I'm attaching a "fix" that allows circumventing the problem with a
> --force switch, patch is relative to "next" branch in git. I'm also
> adding this patch to the Ark Linux package of btrfs-progs unless
> someone screams very loudly. ;)
>
> ttyl
> bero
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-04 9:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-04 9:38 mkfs.btrfs doesn't work inside loopback mounted chroot jails: error checking /dev/sda3 mount status Bernhard Rosenkraenzer
2011-02-04 9:51 ` Felix Blanke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).