Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-image
Commits
045d83ec
Commit
045d83ec
authored
Mar 06, 2014
by
Nikos Skalkotos
Browse files
disklabel.py: Add function for printing warnings
parent
838f63bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-image-helper/disklabel.py
View file @
045d83ec
...
...
@@ -21,6 +21,8 @@
"""This module provides the code for handling BSD disklabels"""
from
__future__
import
print_function
import
struct
import
sys
import
os
...
...
@@ -42,6 +44,11 @@ SBSIZE = 8192 # max size of fs superblock
DISKMAGIC
=
0x82564557
def
warn
(
*
objs
):
"""Print a warning to stderr"""
print
(
"WARNING:"
,
*
objs
,
file
=
sys
.
stderr
)
class
MBR
(
object
):
"""Represents a Master Boot Record."""
class
Partition
(
object
):
...
...
@@ -825,7 +832,7 @@ class OpenBSDDisklabel(DisklabelBase):
assert
end
>
0
,
"No partition found"
if
self
.
ptable
.
part
[
part_num
].
fstype
==
1
:
# Swap partition.
#TODO: Maybe create a warning?
warn
(
"Last partition is swap. Not enlarging it."
)
return
if
end
>
(
self
.
bend
-
1024
):
...
...
@@ -923,19 +930,19 @@ def main():
disk
=
Disk
(
args
[
0
])
if
options
.
list
:
print
disk
print
(
disk
)
return
0
if
options
.
duid
:
print
"%s"
%
""
.
join
(
x
.
encode
(
'hex'
)
for
x
in
disk
.
get_duid
())
print
(
"%s"
%
""
.
join
(
x
.
encode
(
'hex'
)
for
x
in
disk
.
get_duid
())
)
return
0
if
options
.
mapping
:
print
disk
.
linux_partition_mapping
()
print
(
disk
.
linux_partition_mapping
()
)
return
0
if
options
.
last_part
:
print
"%c"
%
chr
(
ord
(
'a'
)
+
disk
.
get_last_partition_id
())
print
(
"%c"
%
chr
(
ord
(
'a'
)
+
disk
.
get_last_partition_id
())
)
return
0
if
options
.
disk_size
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment