From: Goffredo Baroncelli <kreijack@gmail.com>
To: Ian Kumlien <pomac@demius.net>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 6/6] Btrfs-progs: add the rescue section to btrfs
Date: Fri, 08 Feb 2013 18:39:12 +0100 [thread overview]
Message-ID: <51153840.1040004@gmail.com> (raw)
In-Reply-To: <1360283822-23452-7-git-send-email-pomac@demius.net>
On 02/08/2013 01:37 AM, Ian Kumlien wrote:
> the btrfs command now lists:
> btrfs rescue select-super -s <number> <device>
> Select a superblock
> btrfs rescue dump-super <device>
> Dump a superblock to disk
> btrfs rescue debug-tree [options] <device>
> Debug the filesystem
>
> btrfs-dump-super.c was imported in to cmds-rescue-super-ops.c
>
> This patch integrates all the functionality...
>
> cmds-rescue.c is used to glue cmds-rescue-debug-tree.c,
> cmds-rescue-restore.c and cmds-rescue-super-ops.c together to
> make the source files more managable.
[...]
> -int main(int ac, char **av)
> +const char * const cmd_dump_super_usage[] = {
> + "btrfs rescue dump-super <device>",
> + "Dump a superblock to disk",
> + NULL
> +};
[...]
> +int cmd_dump_super(int argc, char **argv)
> +{
> + int i;
> +
> + if (argc != 2)
> + usage(cmd_dump_super_usage);
> +
> + for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
> + u64 bytenr = btrfs_sb_offset(i);
> + int fd;
> + struct btrfs_super_block sb;
> + int block_size = sizeof(struct btrfs_super_block);
> + char filename[1024];
> + int bytes_read = read_block(argv[optind], bytenr, &sb);
> + if (bytes_read < block_size)
> + continue;
I think that we should also implement a check of the superblock checksum.
> +
> + sprintf(filename, "/tmp/block.%s.%llu",
> + strrchr(argv[optind], '/') + 1, bytenr);
> + fd = open(filename, O_CREAT|O_WRONLY, 0644);
This is the part that I don't like. The output file name should be
passed via the command line. It should not be defined by some obscure
logic. The user is able to understand where the sb is written only after.
> + if (block_size != pwrite(fd, &sb, block_size, 0)) {
> + fprintf(stderr, "Failed to dump superblock %d", i);
> + continue;
> + }
> + fprintf(stderr, "Dumped superblock %s:%d, gen %llu to %s.\n",
> + argv[optind], i, sb.generation, filename);
> + close(fd);
> + }
[...]
--
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5
next prev parent reply other threads:[~2013-02-08 17:38 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 0:36 Btrfs-progs: Merge btrfs-restore, btrfsck, btrfs-select-super, btrfs-dump-super and btrfs-debug-tree in to btrfs Ian Kumlien
2013-02-08 0:36 ` [PATCH 1/6] Btrfs-progs: Rename btrfsck.c -> cmds-check.c Ian Kumlien
2013-02-08 0:36 ` [PATCH 2/6] Btrfs-progs: add btrfsck functionality to btrfs Ian Kumlien
2013-02-08 17:39 ` Goffredo Baroncelli
2013-02-08 18:17 ` Ian Kumlien
2013-02-08 23:07 ` David Sterba
2013-02-08 23:37 ` Ian Kumlien
2013-02-12 16:39 ` David Sterba
2013-02-12 17:37 ` Filipe Brandenburger
2013-02-12 18:01 ` Goffredo Baroncelli
2013-02-12 22:52 ` David Sterba
2013-02-12 23:07 ` Goffredo Baroncelli
2013-06-02 15:47 ` Dieter Ries
2013-11-13 17:13 ` David Sterba
2013-11-14 9:25 ` Ilya Dryomov
2013-11-14 12:49 ` David Sterba
2013-11-14 12:56 ` Ian Kumlien
2013-02-08 0:36 ` [PATCH 3/6] Btrfs-progs: move btrfs-select-super.c Ian Kumlien
2013-02-08 0:37 ` [PATCH 4/6] Btrfs-progs: move debug-tree.c -> cmds-rescue-debug-tree.c Ian Kumlien
2013-02-08 0:37 ` [PATCH 5/6] Btrfs-progs: restore.c -> cmds-restore.c Ian Kumlien
2013-02-08 0:37 ` [PATCH 6/6] Btrfs-progs: add the rescue section to btrfs Ian Kumlien
2013-02-08 17:39 ` Goffredo Baroncelli [this message]
2013-02-08 18:07 ` Ian Kumlien
2013-02-08 19:57 ` Ilya Dryomov
2013-02-08 20:48 ` Hugo Mills
2013-02-08 22:30 ` David Sterba
2013-02-12 15:26 ` David Sterba
2013-02-08 17:40 ` Btrfs-progs: Merge btrfs-restore, btrfsck, btrfs-select-super, btrfs-dump-super and btrfs-debug-tree in " Goffredo Baroncelli
2013-02-08 18:05 ` Ian Kumlien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51153840.1040004@gmail.com \
--to=kreijack@gmail.com \
--cc=kreijack@inwind.it \
--cc=linux-btrfs@vger.kernel.org \
--cc=pomac@demius.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).