[Libguestfs] [PATCH] NEW API: add new api btrfs-fsck

Wanlong Gao gaowanlong at cn.fujitsu.com
Tue May 15 07:50:32 UTC 2012


On 05/15/2012 03:43 PM, Richard W.M. Jones wrote:

> On Tue, May 15, 2012 at 10:33:42AM +0800, Wanlong Gao wrote:
>> Add the new API btrfs-fsck to check the btrfs filesystem.
>> Btrfs is currently under heavy development, and not suitable for
>> any uses other than benchmarking and review. But it'll be useful
>> in the near future.
>>
>> Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
>> ---
>>  daemon/btrfs.c                 |   17 +++++++++++++++++
>>  generator/generator_actions.ml |   11 +++++++++++
>>  src/MAX_PROC_NR                |    2 +-
>>  3 files changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/daemon/btrfs.c b/daemon/btrfs.c
>> index ab3babc..62f07f3 100644
>> --- a/daemon/btrfs.c
>> +++ b/daemon/btrfs.c
>> @@ -619,3 +619,20 @@ do_btrfs_set_seeding (const char *device, int svalue)
>>    free (err);
>>    return r;
>>  }
>> +
>> +int
>> +do_btrfs_fsck (const char *device)
>> +{
>> +  char *err;
>> +  int r;
>> +
>> +  r = commandr (NULL, &err, "btrfsck", device, NULL);
>> +  if (r == -1) {
>> +    reply_with_error ("%s: %s", device, err);
>> +    free (err);
>> +    return -1;
>> +  }
>> +
>> +  free (err);
>> +  return r;
>> +}
> 
> This worries me.  Isn't btrfsck interactive?  Ordinary fsck has a
> meaningful exit code, but btrfsck doesn't.  Will it get one in future?


It may because btrfsck is a experimental tool and will change a lot in
the future.

> 
>> diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
>> index fc2df42..33ffd6b 100644
>> --- a/generator/generator_actions.ml
>> +++ b/generator/generator_actions.ml
>> @@ -7232,6 +7232,17 @@ If C<devices> is an empty list, this does nothing.");
>>  Enable or disable the seeding feature of a device that contains
>>  a btrfs filesystem.");
>>  
>> +  ("btrfs_fsck", (RErr, [Device "device"], []), 332, [Optional "btrfs"],
>> +   [InitPartition, IfAvailable "btrfs", TestRun (
>> +     [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
>> +      ["btrfs_fsck"; "/dev/sda1"]])],
>> +   "check a btrfs filesystem",
>> +   "\
>> +Used to check a btrfs filesystem, C<device> is the device file where the
>> +filesystem is stored.
> 
> Put a blank line between paragraphs.
> 
>> +NOTE: Btrfs is currently under heavy development, and not suitable for any
>> +uses other than benchmarking and review.");
> 
> Instead of "NOTE:", it's better to use I<Note:> or B<Note:>
> (see perlpod(1)).


Will send V2.


Thanks,
Wanlong Gao

> 
> Rich.
> 





More information about the Libguestfs mailing list