[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH 1/3] NEW API: add a new api zero_fs



On 02/06/2012 04:26 PM, Richard W.M. Jones wrote:

> On Mon, Feb 06, 2012 at 04:17:05PM +0800, Wanlong Gao wrote:
>> Add the new api zero_fs to erase the filesystem signatures
>> on a device but now erase any data.
>>
>> Signed-off-by: Wanlong Gao <gaowanlong cn fujitsu com>
>> ---
>>  daemon/zero.c                  |   17 +++++++++++++++++
>>  generator/generator_actions.ml |   14 ++++++++++++++
>>  src/MAX_PROC_NR                |    2 +-
>>  3 files changed, 32 insertions(+), 1 deletions(-)
>>
>> diff --git a/daemon/zero.c b/daemon/zero.c
>> index 398f844..348869f 100644
>> --- a/daemon/zero.c
>> +++ b/daemon/zero.c
>> @@ -73,6 +73,23 @@ do_zero (const char *device)
>>  }
>>  
>>  int
>> +do_zero_fs (const char *device)
>> +{
>> +  int r;
>> +  char *err = NULL;
>> +
>> +  const char *wipefs[] = {"wipefs", "-a", device, NULL};
>> +  r = commandv (NULL, &err, wipefs);
>> +  if (r == -1) {
>> +    reply_with_error ("%s", err);
>> +    free (err);
>> +    return -1;
>> +  }
>> +  free (err);
>> +  return 0;
>> +}
>> +
>> +int
>>  do_zero_device (const char *device)
>>  {
>>    int64_t ssize = do_blockdev_getsize64 (device);
>> diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
>> index 3a7be79..d27ef43 100644
>> --- a/generator/generator_actions.ml
>> +++ b/generator/generator_actions.ml
>> @@ -6651,6 +6651,20 @@ This option may not be specified at the same time as the C<correct> option.
>>  
>>  =back");
>>  
>> +  ("zero_fs", (RErr, [Device "device"], []), 305, [Progress],
>> +   [InitBasicFSonLVM, Always, TestRun (
>> +      [["zero_fs"; "/dev/VG/LV"]])],
>> +   "wipe a filesystem signature from a device",
>> +   "\
>> +This command can  erase filesystem or raid signatures (magic strings) from
>> +the specified C<device> to make the filesystem invisible for libblkid.
>> +This does not erase the filesystem itself nor any other data from the C<device>.
>> +Compare with C<guestfs_zero> which just zeroes the first few blocks of a
>> +device, contained the partitions on the device, but this C<guestfs_zero_fs>
>> +can't erase the partitions of a device.
>> +
>> +=back");
>> +
>>  ]
>>  
>>  let all_functions = non_daemon_functions @ daemon_functions
>> diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
>> index 873b744..67d04b9 100644
>> --- a/src/MAX_PROC_NR
>> +++ b/src/MAX_PROC_NR
>> @@ -1 +1 @@
>> -304
>> +305
> 
> Ah, wipefs, I think this is a good idea, and it's been on the
> TODO list for a long time.
> 
> What do people think about calling the API 'wipefs' instead of
> 'zero-fs'?


I've no idea with this, calling 'wipefs' is good, but 'zero-fs' can
be consistent with the "guestfs_zero*" api. So, up to you.

> 
> Can you update the patch to remove the reference to wipefs in the TODO
> file?


sure, done in v2.

Thanks
-Wanlong Gao

> 
> Rich.
> 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]