Revision 0188611b
b/lib/backend.py | ||
---|---|---|
1595 | 1595 |
@param size: The size in MiB to write |
1596 | 1596 |
|
1597 | 1597 |
""" |
1598 |
# Internal sizes are always in Mebibytes; if the following "dd" command |
|
1599 |
# should use a different block size the offset and size given to this |
|
1600 |
# function must be adjusted accordingly before being passed to "dd". |
|
1601 |
block_size = 1024 * 1024 |
|
1602 |
|
|
1598 | 1603 |
cmd = [constants.DD_CMD, "if=/dev/zero", "seek=%d" % offset, |
1599 |
"bs=%d" % constants.WIPE_BLOCK_SIZE, "oflag=direct", "of=%s" % path,
|
|
1604 |
"bs=%s" % block_size, "oflag=direct", "of=%s" % path,
|
|
1600 | 1605 |
"count=%d" % size] |
1601 | 1606 |
result = utils.RunCmd(cmd) |
1602 | 1607 |
|
... | ... | |
1625 | 1630 |
_Fail("Cannot execute wipe for device %s: device not found", disk.iv_name) |
1626 | 1631 |
|
1627 | 1632 |
# Do cross verify some of the parameters |
1633 |
if offset < 0: |
|
1634 |
_Fail("Negative offset") |
|
1635 |
if size < 0: |
|
1636 |
_Fail("Negative size") |
|
1628 | 1637 |
if offset > rdev.size: |
1629 | 1638 |
_Fail("Offset is bigger than device size") |
1630 | 1639 |
if (offset + size) > rdev.size: |
b/lib/constants.py | ||
---|---|---|
129 | 129 |
|
130 | 130 |
# Wipe |
131 | 131 |
DD_CMD = "dd" |
132 |
WIPE_BLOCK_SIZE = 1024 ** 2 |
|
133 | 132 |
MAX_WIPE_CHUNK = 1024 # 1GB |
134 | 133 |
MIN_WIPE_CHUNK_PERCENT = 10 |
135 | 134 |
|
Also available in: Unified diff