Revision 326e0925

b/lib/backend.py
2235 2235
  return device.unique_id
2236 2236

  
2237 2237

  
2238
def _DumpDevice(source_path, target_path, offset, size):
2238
def _DumpDevice(source_path, target_path, offset, size, truncate):
2239 2239
  """This function images/wipes the device using a local file.
2240 2240

  
2241 2241
  @type source_path: string
......
2250 2250
  @type size: int
2251 2251
  @param size: maximum size in MiB to write (data source might be smaller)
2252 2252

  
2253
  @type truncate: bool
2254
  @param truncate: whether the file should be truncated
2255

  
2253 2256
  @return: None
2254 2257
  @raise RPCFail: in case of failure
2255 2258

  
......
2262 2265
  cmd = [constants.DD_CMD, "if=%s" % source_path, "seek=%d" % offset,
2263 2266
         "bs=%s" % block_size, "oflag=direct", "of=%s" % target_path,
2264 2267
         "count=%d" % size]
2268

  
2269
  if not truncate:
2270
    cmd.append("conv=notrunc")
2271

  
2265 2272
  result = utils.RunCmd(cmd)
2266 2273

  
2267 2274
  if result.failed:
......
2348 2355
  if (offset + size) > rdev.size:
2349 2356
    _Fail("Wipe offset and size are bigger than device size")
2350 2357

  
2351
  _DumpDevice("/dev/zero", rdev.dev_path, offset, size)
2358
  _DumpDevice("/dev/zero", rdev.dev_path, offset, size, True)
2352 2359

  
2353 2360

  
2354 2361
def BlockdevImage(disk, image, size):
......
2387 2394
  if utils.IsUrl(image):
2388 2395
    _DownloadAndDumpDevice(image, rdev.dev_path, size)
2389 2396
  else:
2390
    _DumpDevice(image, rdev.dev_path, 0, size)
2397
    _DumpDevice(image, rdev.dev_path, 0, size, False)
2391 2398

  
2392 2399

  
2393 2400
def BlockdevPauseResumeSync(disks, pause):

Also available in: Unified diff