def _zero_volume(path, volume_size):
 bs = units.Mi
 direct_flags = ('oflag=direct',)
 sync_flags = ()
 remaining_bytes = volume_size
 while remaining_bytes:
  zero_blocks = (remaining_bytes // bs)
  seek_blocks = ((volume_size - remaining_bytes) // bs)
  zero_cmd = ('dd', ('bs=%s' % bs), 'if=/dev/zero', ('of=%s' % path), ('seek=%s' % seek_blocks), ('count=%s' % zero_blocks))
  zero_cmd += direct_flags
  zero_cmd += sync_flags
  if zero_blocks:
   utils.execute(run_as_root=True, *zero_cmd)
  remaining_bytes %= bs
  bs //= units.Ki
  direct_flags = ()
  sync_flags = ('conv=fdatasync',)

def _zero_volume ( path , volume_size ) : bs = units . Mi direct_flags = ( 'oflag=direct' , ) sync_flags = ( ) remaining_bytes = volume_size while remaining_bytes : zero_blocks = ( remaining_bytes // bs ) seek_blocks = ( ( volume_size - remaining_bytes ) // bs ) zero_cmd = ( 'dd' , ( 'bs=%s' % bs ) , 'if=/dev/zero' , ( 'of=%s' % path ) , ( 'seek=%s' % seek_blocks ) , ( 'count=%s' % zero_blocks ) ) zero_cmd += direct_flags zero_cmd += sync_flags if zero_blocks : utils . execute ( run_as_root = True , * zero_cmd ) remaining_bytes %= bs bs //= units . Ki direct_flags = ( ) sync_flags = ( 'conv=fdatasync' , )
write zeros over the specified path .