christos
2e738cf025
check allocations
2015-12-02 20:09:54 +00:00
christos
53de6040eb
annotate map additions with non-allocated memory.
2015-12-02 20:09:33 +00:00
christos
c458b37c6c
- check errors from map allocation
...
- make map_resize return -1 instead of 0, and handle errors locally
explaining what's going wrong
2015-12-02 20:01:44 +00:00
christos
2eda9128ae
Allow backup and restore to operate on files.
2015-12-02 12:36:53 +00:00
christos
466f99a5ab
don't advertise stuff we don't support.
2015-12-02 12:24:02 +00:00
christos
ce4e8c4470
Always set NOSYNC if regular file, even if we got the size from the command
...
line.
2015-12-02 12:20:52 +00:00
jnemeth
de2c104cf3
hrmm...
...
i386devel: {245} ./gpt add -b 1000 -s 1000 disk
Segmentation fault (core dumped)
Where's my flyswatter? .......zzzzzzzap
2015-12-02 11:20:34 +00:00
jnemeth
777094fd12
- dereferencing NULL is generally bad, found by visual inspection
...
- automatically set nosync when opening a file to avoid spurious errors
2015-12-02 10:19:58 +00:00
christos
272fa82935
print the old and the new style usage.
2015-12-02 04:17:25 +00:00
christos
cdf86847f5
refactor the utf code so that it does not leak memory.
2015-12-02 04:07:11 +00:00
christos
d1f209293e
split out into smaller functions.
2015-12-02 04:06:47 +00:00
christos
c94670c3be
use the utility function.
2015-12-02 04:06:10 +00:00
christos
b732231137
- write a function to set the entity, so that we don't reset to guid.
...
- entry 0 means create entry.
2015-12-02 01:01:55 +00:00
christos
0f004afe33
merge command line parsers and check all memory allocations.
2015-12-01 23:29:07 +00:00
christos
1c8d6ff1b4
Reflect reality better; we don't handle multiple devices anymore, and
...
the partitions option is only for the commands that support it.
2015-12-01 22:49:25 +00:00
christos
bbb4a8ab26
refactor more duplicated code.
2015-12-01 19:25:24 +00:00
christos
6fb89396f8
automatically enforce readonly for the commands that don't need to write.
2015-12-01 16:33:55 +00:00
christos
8ca93e4658
Refactor the command dispatching and help printing logic.
2015-12-01 16:32:19 +00:00
christos
0b43d398b9
Firs step of refactoring, remove all globals, factor out some common code,
...
handle alternate usage but not advertise it.
2015-12-01 09:05:33 +00:00
christos
68bc3825b8
- use gpt_msg to print informational messages (perhaps these should be printed
...
only with -v)
- don't print any messages with gpt_msg if quiet
- print a message if we didn't reconfigure the wedges
2015-12-01 02:03:55 +00:00
christos
835e6be8c3
only update the wedge information if it is supported.
2015-12-01 01:49:23 +00:00
christos
e4ed2565fe
- automatically sync the wedge information unless -n is specified.
...
- document the general options in the traditional way.
- split the main program into a separate file.
2015-11-30 19:59:34 +00:00
christos
7e254cfb82
Remove getdisksize support; we either have the ioctls (current/-7) or we
...
don't (non-netbsd-current/7+tools).
2015-11-29 15:32:46 +00:00
christos
2d178fa50d
Add the missing cases.
2015-11-29 14:12:56 +00:00
christos
4ab2c2d9c7
Add some debugging.
2015-11-29 14:12:35 +00:00
christos
c313281022
Do division once
2015-11-29 14:03:35 +00:00
christos
f8906ab68d
Only use the ioctl's if we have them.
2015-11-29 13:46:23 +00:00
jnemeth
1ca10bc795
fix build breakage for systems that do not have DIOCG{SECTOR,MEDIA}SIZE
2015-11-29 13:24:28 +00:00
christos
2599c179cc
print the current map type.
2015-11-29 00:34:39 +00:00
christos
5435e55eab
- use snprintf
...
- fix bogus logic on map_type
2015-11-29 00:15:12 +00:00
christos
ca4e0dcdd1
merge the create errors in one place and fix them.
2015-11-29 00:14:46 +00:00
jnemeth
6141a178e3
correctly print the gpt header revision as a "float"
2015-11-16 12:24:13 +00:00
jnemeth
902aecab13
Add a "header" subcommand that displays information about the size of
...
the disk along with information from the GPT header if it exists.
2015-11-03 02:19:24 +00:00
mlelstv
733f23562f
A change to the GPT_TYPE list also requires a change to the GPT_TYPE
...
index constants.
2015-09-04 17:59:53 +00:00
jnemeth
29c769ab8c
Instruct user to use resizedisk if media size has changed, as
...
resizedisk will adjust the media size in the headers, whereas
recover simply copies the existing header over the missing one.
XXX recover and resizedisk should probably be merged (even if just
partially, so that recover can properly handle media size changes).
Also, reading in the GPT should probably be centralised so that
error handling can be centralised, and users aren't given misleading
messages (i.e. they aren't told to run recover when they should be
running resizedisk). However, something that can be quickly pulled
up to netbsd-7 was needed, and there isn't time for a major overhaul
or rewrite.
2015-06-18 01:37:23 +00:00
christos
d3037dba83
fix error messages containing \n
2015-06-16 23:18:54 +00:00
christos
ccbdb0d177
Factor out the getdisksize() drvctl method, and provide an alternative that
...
directly uses the disk ioctl's instead of relying on the drvctl device driver
which is currently not mandatory.
2014-12-29 16:27:06 +00:00
mlelstv
9171ddc6ae
Fix handling of -t option for the type command.
...
Match any type, when no option is given, just like for the label command.
2014-12-07 09:51:42 +00:00
wiz
d12dcb884c
Bump date for previous.
2014-12-06 21:53:55 +00:00
mlelstv
c3505b64dc
Add some more common partition types.
2014-12-06 12:24:22 +00:00
mlelstv
96f40a63cc
handle constness better
2014-11-17 07:15:28 +00:00
mlelstv
477be5f2de
handle constness
2014-11-17 07:13:42 +00:00
mlelstv
8e3b364b00
Report the argument instead of (null) when opendisk fails.
2014-11-17 07:11:18 +00:00
riastradh
c4ba54210e
Paranoia: choke noisily on EOF from /dev/urandom.
2014-10-04 11:23:35 +00:00
riastradh
ba983c7779
Make gpt(8) generate v4 (random) uuids.
...
Don't needlessly leak your date/time and MAC address when you edit
the disk.
Read from /dev/urandom rather than calling arc4random or anything,
since this is a tool. (Cygwin seems to have /dev/urandom, but yell
if this breaks the build on your exotic platform because it lacks
/dev/urandom.)
ok apb
2014-10-04 10:30:13 +00:00
wiz
ec23d78824
Remove trailing whitespace.
2014-10-04 07:15:54 +00:00
christos
279da39389
Allow specifying sector and media size on the command line.
2014-10-04 01:00:42 +00:00
christos
194a5fe433
provide a copy of the kernel uuid generator (with portable API calls) for
...
tools.
2014-10-03 20:30:06 +00:00
jnemeth
00433a3409
"0" is not guaranteed to be unique
2014-10-03 00:51:31 +00:00
apb
1029f7d668
include <sys/endian.h> for both the non-tools build,
...
and the tools build on a host where the file exists.
Fixes a build problem on FreeBSD, reported by Herbert J. Skuhra, where
tools/compat's configure detected that be32dec() and friends were
available in the host's <sys/endian.h>, so tools/compat did not provide
its own versions.
2014-10-02 21:27:41 +00:00
joerg
1a21d263f9
Fix tools build on !NetBSD.
2014-10-02 19:15:21 +00:00
apb
f685c2f61e
It's HAVE_NBTOOL_CONFIG_H, not HAVE_NBTOOLS_CONFIG_H
2014-10-01 12:55:39 +00:00
jnemeth
870b6dcbee
oops, forgot to update end of data area
2014-10-01 03:52:42 +00:00
jnemeth
c4b5bb5337
using random values for hdr->hdr_guid does not work very well
2014-10-01 01:08:25 +00:00
jnemeth
0d4fdcc249
actually return the uuid when parsing one that is in numeric format
2014-10-01 01:07:24 +00:00
jnemeth
20f10808c3
correctly show partition type in the new world order
2014-09-30 22:56:36 +00:00
jnemeth
0e826d2ca3
Check size of correct buffer. Note, just being pedantic as the buffer
...
being checked is the same size as the one that should have been checked.
2014-09-30 20:23:23 +00:00
christos
21c34dbb1d
Add internal uuid support, since the linux+macos versions of the library
...
are different than than *bsd ones, and others might not have it at all.
2014-09-30 17:59:59 +00:00
christos
c917041fda
remove compat defines.
2014-09-30 02:12:55 +00:00
christos
4da1cfa89d
more toolification changes
2014-09-29 22:22:03 +00:00
christos
866082940a
more toolification
2014-09-29 21:04:34 +00:00
christos
a50708a134
minor toolification: need libprop...
2014-09-29 20:28:57 +00:00
jnemeth
ac204e48a2
PR/47990 - Dr. Wolfgang Stukenbrock -- add "-L <label>" as selector option
2014-09-29 05:56:43 +00:00
jnemeth
88085c2f28
PR/44218 - David Young -- add "type" subcommand to change a partition type
2014-09-28 08:14:51 +00:00
jnemeth
e4be9d18c3
- handle a GPT that isn't an exact multiple of a sector
...
- adjust PMBR size, in case new disk is a different size
- don't leak as much memory
- clean up error handling somewhat
2014-09-26 08:56:34 +00:00
jnemeth
ede6a6c556
no C99isms in tool code
2014-09-26 05:34:15 +00:00
msaitoh
3821b76445
Fix compile error observed on i386. Use PRIu64.
2014-09-23 13:48:04 +00:00
jnemeth
2ed5cc2617
- make gpt_gpt() available for use directly by subcommands
...
- create new resizedisk disk subcommand for relocating backup GPT
2014-09-23 07:47:54 +00:00
jnemeth
4013e132a3
document the new restore subcommand
2014-09-20 22:36:09 +00:00
jnemeth
06190c9314
Initial cut of gpt restore. This functions correctly in testing,
...
but isn't all that pretty. It has minimal error testing and may
leak memory. It also only works with empty disks. If passed "-F"
flag, it will blank the disk for you.
2014-09-20 22:11:27 +00:00
jnemeth
e3f4016378
- dump all partitions, not just ones that are in use
...
- while here, squash a memory leak
It shouldn't be necessary to backup unused partitions, however
the partition GUID is created at the time the GPT is created and
is never changed. It shouldn't matter if the GUID of an unused
partition changes, but there may be some special case where it
does. Since it isn't a big deal to record the unused partitions,
might as well do it.
2014-09-10 10:49:44 +00:00
jnemeth
ef9cc4e43f
- record the sector size of the disk
...
- correct confusion with end_cylinder and end_sector in MBRs
2014-09-09 06:30:09 +00:00
jnemeth
3170c9b01c
Add restore subcommand.
...
XXX It does not actually work yet. It is being committed now to make
later pullups easier.
2014-08-10 18:27:15 +00:00
wiz
b07680d7fe
Bump date for previous.
2013-12-19 07:49:50 +00:00
jnemeth
4fb24d0cac
Add the backup subcommand. It dumps the contents of the partition
...
tables as a plist, which is readable by the restore subcommand.
XXX restore subcommand forthcoming
2013-12-19 06:46:51 +00:00
jnemeth
6f2d9e3758
If we want to GUIDs to display with correct endian, it helps to decode it first.
2013-12-18 03:20:09 +00:00
jnemeth
53733ab887
Explicitly state which partition was added/modified.
2013-12-10 01:05:00 +00:00
wiz
918b300e20
Fix typo.
2013-12-09 09:22:44 +00:00
jnemeth
1cb2b94165
Add two new subcommands, "set" and "unset". These were inspired by
...
FreeBSD's gpart(8), but the code is all mine. The purpose of these
is to set and unset partition attributes.
2013-12-09 08:03:17 +00:00
jnemeth
66ad0e75ae
For the "show -i <entry>" subcommand, print Start and Size both in
...
terms of number of sectors and bytes.
2013-12-09 01:35:02 +00:00
jnemeth
2098c8504e
For the add and resize subcommands, change the -s option. If there is
...
no suffix, or the suffix is 's' or 'S', size is in sectors (as before)
otherwise size is in bytes.
2013-12-08 09:32:51 +00:00
jnemeth
e3e68bccc8
fix off-by-one error
2013-12-08 08:30:01 +00:00
jnemeth
024b3f7622
Don't attempt to create/resize an unaligned partition if the attempt
...
to create/resize an aligned one failed. This simplifies the code
and prevents surprises. If the user wants an unaligned partition
in the case where an aligned one fails, they can simply retry the
command without the "-a" option. This change was requested by
wiz@, and after some thought I agree with it.
2013-12-06 02:31:31 +00:00
jakllsch
16550bc8bd
Use MBR_PTYPE_ defines from <sys/bootblock.h>.
2013-12-04 20:15:51 +00:00
jakllsch
e22b4ebb4a
Mirror my changes of src/sbin/gpt/create.c 1.4 in migrate.c;
...
Use less bogus CHS addresses in PMBR.
With the ending head set at 0xff one machine I have will never leave
the initial startup screen if such a disk is present. Additionally,
Wikipedia suggests without citiation that 254 is the maximium allowable
value for the head, and this seems to be the case.
2013-12-04 19:59:47 +00:00
jnemeth
925666ef9b
Add two new options:
...
-g which shows the GUID for a partition
-i which shows all the gory details for a particular option
XXX the output format of -i is subject to change
2013-11-30 19:43:53 +00:00
jnemeth
2b199b9458
when calling dehumanize_number() make sure the resulting number is >= 1
2013-11-28 01:37:14 +00:00
christos
d873a92b9b
CID 1132762: Add error check for negative, to make zero-divide in module
...
impossible.
2013-11-27 20:40:48 +00:00
christos
bb7996ed1a
CID 1132764: Bogus test
2013-11-27 20:34:34 +00:00
jnemeth
9299334f79
Remove FreeBSD specific code as per message to tech-userlevel.
2013-11-27 01:47:53 +00:00
jnemeth
e066617c02
Only skip past _PATH_DEV if it is actually present.
2013-11-23 08:59:04 +00:00
jnemeth
9ceccfb63b
change the "-b blocknr" parameter to accept a "human number"
2013-11-22 04:21:02 +00:00
jnemeth
d883a91427
bump date
2013-11-22 03:51:06 +00:00
jnemeth
4f22d16faa
In the manpage:
...
- s/-b number/-b blocknr/
- s/-s count/-s sectors/
- s/-p count/-p partitions/
In the program:
- s/-b lba/-b blocknr/
- s/-s lba/-s sectors/
This makes the documentation in the manpage and the program consistent
and makes it more clear what the parameters are. Also, "-s lba" was
just plain wrong since LBA stands for Logical Block Address[ing], and
the -s option didn't represent any kind of address, but rather a size.
2013-11-22 03:50:05 +00:00
wiz
00996309f7
shrunk.
2013-11-20 08:11:36 +00:00
jnemeth
0a08058311
Add a resize command. This command was inspired by FreeBSD's gpart(8),
...
but the code was written by myself.
2013-11-20 08:08:47 +00:00
jnemeth
49ca570b23
delete an errant where it is obvious what the code is doing
2013-11-19 22:41:43 +00:00
jnemeth
477692ee49
When setting a label on the new partition, be sure to set the label
...
in the secondary partition table as well.
2013-11-19 19:10:29 +00:00
jnemeth
a3d649686c
update synopsis for add subcommand
2013-11-19 05:07:40 +00:00
jnemeth
650728b4e3
Add two new options to the "add" subcommand:
...
-a alignment -- attempt to align the start and size of the partition
-l label -- supply a label for the partition
These options were inspired by FreeBSD's gpart(8) command, but the
code was written by me.
2013-11-19 05:03:41 +00:00