OpenBSD CVS

CVS log for src/sbin/fdisk/misc.c


[BACK] Up to [local] / src / sbin / fdisk

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.88 / (download) - annotate - [select for diffs], Sun Jul 10 20:34:31 2022 UTC (22 months, 3 weeks ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, HEAD
Changes since 1.87: +9 -3 lines
Diff to previous 1.87 (colored)

Add some anti-feline input protection by refusing to process
input of excessive length.

Make 'args' parameter to Xfuncs const char * and do the multiple
argument parsing in Xswap() and Xflag() on a local copy.

Revision 1.87 / (download) - annotate - [select for diffs], Wed Apr 20 15:49:56 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.86: +1 -35 lines
Diff to previous 1.86 (colored)

Simpify code manipulating GPT partition names by coalescing
logic into GPT_get_name(), string_to_name() and name_to_string()
functions. Remove unnecessarily abstract functions ask_string(),
utf16le_to_string() and string_to_utf16le().

No intentional functional change.

Revision 1.86 / (download) - annotate - [select for diffs], Mon Sep 13 15:07:51 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.85: +13 -5 lines
Diff to previous 1.85 (colored)

disk.dk_size can't be 0 as we errx() if that happens during
DISK_open(). So eliminate pointless check when printing geometry.

Replace unit_lookup() with units_size(), reducing four
conversion dances to one. Return pointer to the unit_type used in
the conversion. unit_types[] is now needed only in misc.c.

Fewer variables make for cleaner logic.

No intentional functional change.

Revision 1.85 / (download) - annotate - [select for diffs], Sun Sep 12 16:36:52 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.84: +4 -3 lines
Diff to previous 1.84 (colored)

Stop taking detour through unit_types[SECTORS] to find
dl.d_secsize.

Leave unit_types[SECTORS].ut_conversion at 0, and test that to
determine if a size needs to be converted from a sectors value.

Use consistent dance to find the desired size value to print.

Logic is clearer, unit_types[] is now const, nobody but misc.c
knows about SECTORS.

No intentional functional change.

Revision 1.84 / (download) - annotate - [select for diffs], Fri Sep 10 15:26:36 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.83: +4 -6 lines
Diff to previous 1.83 (colored)

Stop using NULL as a synonym for "s" (SECTORS). Just use "s".
Remove now pointless NULL check in unit_lookup().

No intentional functional change.

Revision 1.83 / (download) - annotate - [select for diffs], Thu Sep 9 12:36:45 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.82: +8 -13 lines
Diff to previous 1.82 (colored)

Scan unit_types[] array using nitems() and eliminate the NULL
sentinal entry.

No functional change.

Revision 1.82 / (download) - annotate - [select for diffs], Sat Aug 28 11:55:17 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.81: +19 -1 lines
Diff to previous 1.81 (colored)

Add hex_octet() so the strtol(..,16) dance is done in just one
place.

Allows single-digit partition id's in '-b' as a side benefit.

Revision 1.81 / (download) - annotate - [select for diffs], Tue Aug 24 12:34:04 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.80: +18 -6 lines
Diff to previous 1.80 (colored)

Trim leading/trailing whitespace from -e input to make command
parsing more robust (e.g. 'edit 0 ' is now accepted) and strict
(e.g. 'reinit gptx' is now rejected).

Input which may want that whitespace is not trimmed (e.g. GPT
partition names).

Use consistent definition of whitespace corresponding to that
used by isspace().

Revision 1.80 / (download) - annotate - [select for diffs], Sun Aug 15 13:45:42 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.79: +5 -10 lines
Diff to previous 1.79 (colored)

Don't check & errx() after each and every invocation of
string_from_line(). Just errx() inside string_from_line() if
getline() fails.

Use strcspn() idiom to nuke '\n' returned by getline().

No functional change.

Revision 1.79 / (download) - annotate - [select for diffs], Sat Aug 7 13:33:12 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.78: +1 -3 lines
Diff to previous 1.78 (colored)

Nuke unneeded #include's, one param.h -> types.h.

Revision 1.78 / (download) - annotate - [select for diffs], Sat Jul 17 14:16:34 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.77: +1 -2 lines
Diff to previous 1.77 (colored)

Nuke a bunch of Capt. Obvious or misleading comments.

No functional change.

Revision 1.77 / (download) - annotate - [select for diffs], Fri Jul 16 13:26:04 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.76: +2 -2 lines
Diff to previous 1.76 (colored)

Be consistent and always return -1 to indicate failure.

DISK_printgeometry() return value was always 0 and never
checked so just make it void.

No functional change.

Revision 1.76 / (download) - annotate - [select for diffs], Thu Jul 15 21:58:02 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.75: +2 -2 lines
Diff to previous 1.75 (colored)

No need for separate b_sectors, b_offset and b_type variables. We have struct
prt to hold this info in one place.

Construct a struct prt to hold the boot partition information and stash it in
the struct disk for both MBR and GPT to access as needed.

Move the blocks to sectors conversions into DISK_open() with all of its
geometry friends.

No intentional functional change.

Revision 1.75 / (download) - annotate - [select for diffs], Mon Jul 12 22:18:54 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.74: +5 -4 lines
Diff to previous 1.74 (colored)

Toss 'const' in anywhere the compiler doesn't complain about, thus identifying
places that *should* be const but currently aren't and preventing the rot from
spreading further while those issues are dealt with.

No functional change.

Revision 1.74 / (download) - annotate - [select for diffs], Mon Jul 12 18:31:53 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.73: +5 -5 lines
Diff to previous 1.73 (colored)

Final batch of struct field name tweaks. 'cmd_' for cmd, ut_' for
unit_types, 'pt_' for part_type, 'pg_' for protected_guid.

No functional change.

Revision 1.73 / (download) - annotate - [select for diffs], Mon Jul 12 14:06:19 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.72: +2 -2 lines
Diff to previous 1.72 (colored)

Add 'dk_' prefix to struct disk field names.

No functional change.

Revision 1.72 / (download) - annotate - [select for diffs], Sun Jul 11 13:51:42 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.71: +1 -193 lines
Diff to previous 1.71 (colored)

Move ask_cmd(), ask_num(), ask_pid(), ask_string(), parse_b()
and crc32().

No functional change.

Revision 1.71 / (download) - annotate - [select for diffs], Sun Jul 11 13:38:27 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.70: +33 -33 lines
Diff to previous 1.70 (colored)

Add tabs to make variable declarations easier
to read.

No functional change.

Revision 1.70 / (download) - annotate - [select for diffs], Sun Jul 11 12:51:36 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.69: +16 -16 lines
Diff to previous 1.69 (colored)

'return' is not a function call.

No functional change.

Revision 1.69 / (download) - annotate - [select for diffs], Fri Jun 25 19:24:53 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.68: +10 -9 lines
Diff to previous 1.68 (colored)

Replace instances of the magic number '64' with a nice #define
BLOCKALIGNMENT. This will make it more obvious where this
512-byte block count could/should be converted to a disk sector
count.

No functional change.

Revision 1.68 / (download) - annotate - [select for diffs], Sun Jun 20 18:44:19 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.67: +51 -1 lines
Diff to previous 1.67 (colored)

Make -b available to architectures other than amd64 and i386.

Extend the syntax to allow the boot partition offset and boot
partition type to be specified if needed.

ok deraadt@ kettenis@

Revision 1.67 / (download) - annotate - [select for diffs], Sun Jun 13 14:14:56 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.66: +2 -2 lines
Diff to previous 1.66 (colored)

UUID_STR_LEN+1 is less mysterious than '37'.

Revision 1.66 / (download) - annotate - [select for diffs], Thu Jun 10 15:21:19 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.65: +3 -3 lines
Diff to previous 1.65 (colored)

Toss in 'const' for the parameters to string_to_utf16le() and
utf16le_to_string().

No functional change.

Revision 1.65 / (download) - annotate - [select for diffs], Fri May 7 22:15:13 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.64: +10 -10 lines
Diff to previous 1.64 (colored)

Replace random mix of u_int* and uint* types with consistent uint* types.

Revision 1.64 / (download) - annotate - [select for diffs], Sun Jan 31 14:24:47 2021 UTC (3 years, 4 months ago) by naddy
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.63: +9 -11 lines
Diff to previous 1.63 (colored)

replace fgetln(3) with getline(3) in fdisk

ok millert@

Revision 1.63 / (download) - annotate - [select for diffs], Wed Jul 3 03:24:01 2019 UTC (4 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.62: +2 -2 lines
Diff to previous 1.62 (colored)

snprintf/vsnprintf return < 0 on error, rather than -1.

Revision 1.62 / (download) - annotate - [select for diffs], Thu Nov 16 11:08:28 2017 UTC (6 years, 6 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.61: +5 -3 lines
Diff to previous 1.61 (colored)

Range check default values so that a range like
'[1 - 0] [1]' can no longer return '1'.

Issue reported by Alexi Malinin via bugs@. Thanks!

Revision 1.61 / (download) - annotate - [select for diffs], Thu Nov 26 08:15:07 2015 UTC (8 years, 6 months ago) by tim
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.60: +2 -2 lines
Diff to previous 1.60 (colored)

When prompting for a GPT partition type, use the partition's current type as
default; OK krw@

Revision 1.60 / (download) - annotate - [select for diffs], Thu Nov 26 08:10:42 2015 UTC (8 years, 6 months ago) by tim
Branch: MAIN
Changes since 1.59: +3 -2 lines
Diff to previous 1.59 (colored)

When prompting for an LBA, show the min and max values in the prompt; OK krw@

Revision 1.59 / (download) - annotate - [select for diffs], Sat Nov 21 16:45:41 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.58: +5 -3 lines
Diff to previous 1.58 (colored)

Bring GPT partition editing into line with MBR partition editing
by presenting the existing offset and size as the defaults. Enhance
getuint64() to take a minimum value as ask_num() does. Use this to
ensure that GPT partitions are constrained to the valid area of the
disk. Leave MBR partition constraints alone for the moment.

Original problem(s) noted by tim@

Revision 1.58 / (download) - annotate - [select for diffs], Thu Nov 19 16:14:08 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.57: +4 -3 lines
Diff to previous 1.57 (colored)

Reduce overburden of unnecessary #include's. Note that param.h is
included only for DEV_BSIZE.  Use INT64_MAX instead of LLONG_MAX
so stdint.h is enough.  General tidying up of #include sections.

ok GCC

Revision 1.57 / (download) - annotate - [select for diffs], Thu Nov 12 17:54:50 2015 UTC (8 years, 6 months ago) by tim
Branch: MAIN
Changes since 1.56: +6 -9 lines
Diff to previous 1.56 (colored)

Simplify string_from_line(). No functional change.

OK krw@

Revision 1.56 / (download) - annotate - [select for diffs], Thu Nov 12 15:07:41 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.55: +13 -14 lines
Diff to previous 1.55 (colored)

Avoid problems with pathological input during edit operations. i.e. never
attempt to use data past the end of the input.

Since the return value of ask_cmd() is never checked, make it void instead
of int.

Problems found, original diff from and ok tim@.

Revision 1.55 / (download) - annotate - [select for diffs], Tue Nov 3 14:20:00 2015 UTC (8 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.54: +7 -7 lines
Diff to previous 1.54 (colored)

Don't allow the user to enter GPT partition names too large to fit
in the GPT partition structure. And don't run off the end of the
name buffer by confusing sizeof() with the number of elements in
an array.  Use the new GPTPARTNAMESIZE #define instead. While here,
zap the old partition name before setting the new one, lest a short
new name leave bits of an old long name in place.

Originally spotted by jsg@ and his friend cppcheck.

ok jsg@ for slightly different version.

Revision 1.54 / (download) - annotate - [select for diffs], Mon Oct 26 15:08:26 2015 UTC (8 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.53: +85 -56 lines
Diff to previous 1.53 (colored)

Add GPT editing. Based on GSOC 2014 work by Markus Muller.

Revision 1.53 / (download) - annotate - [select for diffs], Wed Oct 7 00:04:57 2015 UTC (8 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.52: +9 -1 lines
Diff to previous 1.52 (colored)

Note permissions for the crc32() code adapted from Hacker's Delight.

Prompted by deraadt@.

Revision 1.52 / (download) - annotate - [select for diffs], Thu Aug 27 20:58:27 2015 UTC (8 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.51: +3 -3 lines
Diff to previous 1.51 (colored)

Nuke some trailing whitespace that keeps coming back.

Revision 1.51 / (download) - annotate - [select for diffs], Mon Mar 30 17:11:49 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.50: +1 -63 lines
Diff to previous 1.50 (colored)

Even better -- readsector() and writesector() become DISK_readsector() and
DISK_writesector() and live in disk.[ch].

Revision 1.50 / (download) - annotate - [select for diffs], Sun Mar 29 21:16:39 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.49: +63 -1 lines
Diff to previous 1.49 (colored)

Rename MBR_readsector() and MBR_writesector() to just readsector()
and writesector(). Move them to misc.[ch]. Soon to be used for more
than MBR reading/writing.

No intentional functional change.

Revision 1.49 / (download) - annotate - [select for diffs], Sat Mar 28 13:29:16 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.48: +24 -1 lines
Diff to previous 1.48 (colored)

Add a simple crc32() implmentation to avoid pulling in libz, which
would complicate install media. Will be used by GPT support.

Revision 1.48 / (download) - annotate - [select for diffs], Thu Mar 26 20:32:10 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.47: +34 -3 lines
Diff to previous 1.47 (colored)

Adapt ask_string() from disklabel's getstring(). It will be used
to obtain GPT partition names. Tweak ask_pid() to take low/high
bounds so it can handle 1-ff (MBR) or 1000-ffff (GPT) partition
pids as required. A pid of '0' is still special and disables the
partition.

No visible or intentional functional change.

Revision 1.47 / (download) - annotate - [select for diffs], Thu Mar 26 16:32:16 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.46: +10 -8 lines
Diff to previous 1.46 (colored)

Allow input/printing/conversion of terabyte sizes. Which GPT partitons
will eventually be able to use.

Revision 1.46 / (download) - annotate - [select for diffs], Thu Mar 26 14:08:12 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.45: +15 -10 lines
Diff to previous 1.45 (colored)

Expand internal representation of partition starting LBA and size
to 64 bits, adjusting printf()'s, etc. as required. Preparing for
GPT partitions. Add 't' size unit. No other intentional functional
change.

Revision 1.45 / (download) - annotate - [select for diffs], Mon Mar 16 23:51:50 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.44: +3 -3 lines
Diff to previous 1.44 (colored)

Stop passing around a pointer to the stack variable 'disk' in main().
There is only one disk being worked on, so just make it a global.

Fewer parameters, less confusion, no functional change.

Revision 1.44 / (download) - annotate - [select for diffs], Sat Mar 14 18:32:29 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.43: +2 -1 lines
Diff to previous 1.43 (colored)

Whitespace & KNF tweaks. Change functions whose return values are
not checked to void. Use continue inside a do loop instead of a
goto to the top. Move a #define/#undef more local to use. Eliminate
some lint.

General cleanup of things noticed preparing the big churn.

No intentional functional change.

Revision 1.43 / (download) - annotate - [select for diffs], Sat Mar 14 15:21:53 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.42: +11 -20 lines
Diff to previous 1.42 (colored)

Switch all the license blocks to the standard OpenBSD/ISC license.

With the permission of Toby.

ok deraadt@

Revision 1.42 / (download) - annotate - [select for diffs], Mon Mar 31 19:50:52 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.41: +1 -37 lines
Diff to previous 1.41 (colored)

Nuke [get|put][short|long] and just use letoh[16|32] and
htole[16|32]. This is made possible by a) copying unaligned data
(struct dos_partition's) into properly aligned structs and accessing
the fields of the same; and b) realizing that gcc is smart enough to
access fields in packed struct's *if* it knows it is accessing a
packed struct. Even sparc64 finally gave a thumbs up.

After several attempts and feedback from deraadt@ and dlg@, it looks
good to deraadt@.

Revision 1.41 / (download) - annotate - [select for diffs], Thu Mar 20 13:18:21 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.40: +4 -1 lines
Diff to previous 1.40 (colored)

Add back various #includes of err.h, unistd.h, ctype.h, ioctl.h to
eliminate multiple 'implicit' declarations introduced by the previous
over-zealous #include cleanup.

Thanks to to tedu@ for pointing out how -Wall reveals all.

Revision 1.40 / (download) - annotate - [select for diffs], Thu Mar 20 02:08:29 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.39: +2 -1 lines
Diff to previous 1.39 (colored)

Add back #include <stdlib.h> so strtod() works better. Fixes fdisk on
sparc64 at least.

Found when deraadt@ complained about loongson miniroot blowing up.

Revision 1.39 / (download) - annotate - [select for diffs], Mon Mar 17 16:40:00 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.38: +6 -6 lines
Diff to previous 1.38 (colored)

Nuke pointless blank lines, defines, comments and casts. Eliminate
#include in *.h files in favour of listing them as required in the *.c
files. Fix error message to correctly state that 64 is the minimum
value for -l. Use errx() where errno is not relevant. Use 'continue'
rather than a label to go back to start of a loop.

No intentional functional change.

Revision 1.38 / (download) - annotate - [select for diffs], Mon Mar 17 13:15:44 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.37: +2 -2 lines
Diff to previous 1.37 (colored)

Un-revert, being careful to not break snap building. Add paranoia check
for any missing geometry.

Revision 1.37 / (download) - annotate - [select for diffs], Fri Mar 14 15:41:33 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.36: +2 -2 lines
Diff to previous 1.36 (colored)

Revert last -- broke building snaps.

Revision 1.36 / (download) - annotate - [select for diffs], Thu Mar 13 12:02:28 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

Merge 'struct DISK_metrics' and 'struct disk' into one, since we don't
need to record two sets of metric/geometry data. Use 'geometry'
instead of 'metrics' in names and comments. Eliminate
DISK_getmetrics().

While here, make 64 the minimal valid value for '-l' instead of 1. This
avoids the possibility of having 0 cylinders.

No intentional functional change.

Feedback & tweak from chris@

Revision 1.35 / (download) - annotate - [select for diffs], Mon Mar 10 21:40:58 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.34: +6 -6 lines
Diff to previous 1.34 (colored)

No need to pass the name of the command to the function that is
implementing that command, a pointer to the command arguments is the
only thing needed. No need to have a pointer to the command table in
every command, since there is only one table. No need for shiney new
stack space for every command name and arguments parsed, since we
don't recurse we can just use static memory.

No intentional functional change.

Revision 1.34 / (download) - annotate - [select for diffs], Sun Mar 9 22:25:06 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.33: +3 -6 lines
Diff to previous 1.33 (colored)

Instead of passing around 'char buf[DEV_BSIZE]' buffers, pass around
'struct dos_mbr' variables, since that is what the buffers were used
for. Removes need to know about DEV_BSIZE and thus include param.h
from all files but one so move the param.h #include to that file
(mbr.c).

Nuke a bunch of local MBR #defines in favour of the disklabel.h ones.

Remove a bunch of unneeded #includes, replace the odd malloc/bzero
with calloc, replace equally odd bcopy's with memcpy, remove a stray
duplicate MBR parsing in MBR_pcopy().

No intentional functional change.

Revision 1.33 / (download) - annotate - [select for diffs], Fri Mar 7 21:56:13 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.32: +3 -3 lines
Diff to previous 1.32 (colored)

Relieve the code of an overburden of unnecessary typedef
abstraction. Call a 'struct' a 'struct' and not a pony.

No functional change.

idea ok deraadt@

Revision 1.32 / (download) - annotate - [select for diffs], Fri Nov 22 04:12:47 2013 UTC (10 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.31: +2 -2 lines
Diff to previous 1.31 (colored)

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert

Revision 1.31 / (download) - annotate - [select for diffs], Thu Mar 21 18:45:58 2013 UTC (11 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.30: +3 -2 lines
Diff to previous 1.30 (colored)

more substantial include cleanup

Revision 1.30 / (download) - annotate - [select for diffs], Tue Aug 14 08:48:42 2012 UTC (11 years, 9 months ago) by chl
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.29: +2 -2 lines
Diff to previous 1.29 (colored)

remove unused variable

ok krw@

Revision 1.29 / (download) - annotate - [select for diffs], Wed Jul 11 10:27:34 2012 UTC (11 years, 10 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.28: +93 -74 lines
Diff to previous 1.28 (colored)

Simplify guts and calling of getuint(). Eliminate a useless 'help'
capablity by using help text as regular prompt for 'size' and
'offset'. Try to detect and handle more overflow/underflow conditions
in getuint() and ensure returned value is always within requested
bounds. Handle zero-length partitions by treating them as UNUSED.

tested & ok halex@

Revision 1.28 / (download) - annotate - [select for diffs], Mon Jul 9 17:19:55 2012 UTC (11 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.27: +29 -34 lines
Diff to previous 1.27 (colored)

We always want to do unit conversions. So flags parameter of getuint()
is now superflous. With rounding gone the offset parameter is
similarly superfluous. Simply getuint() accordingly.

Revision 1.27 / (download) - annotate - [select for diffs], Mon Jul 9 17:07:35 2012 UTC (11 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.26: +1 -24 lines
Diff to previous 1.26 (colored)

I want some of what kjell was smoking 10 years ago when he added
units handling by copying getuint() from disklabel. MBR partition id
and disklabel partition type are different beasts. So deciding to
round off a MBR partition with id FS_BSDFFS meant rounding off
NTFS partitions. And FS_SWAP partitions meant DOS FAT 12. So just
nuke rounding off for now to simplify getuint().

ok beck@

Revision 1.26 / (download) - annotate - [select for diffs], Mon Jul 9 12:45:30 2012 UTC (11 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.25: +10 -13 lines
Diff to previous 1.25 (colored)

Use strtonum() instead of strtol() inside ask_num(). Many overflows
are thus avoided. Since bounds are now reliable don't check the
returned value for being in-bounds. Since default value is
forced inside bounds, don't bother being tricky and passing a
default that is outside the bounds being specified.

ok beck@

Revision 1.25 / (download) - annotate - [select for diffs], Sun Jul 8 18:29:28 2012 UTC (11 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.24: +5 -3 lines
Diff to previous 1.24 (colored)

set_pid() does not need prompt string, low or high parameters. These
are all constants. Independantly suggested by guenther@.

Revision 1.24 / (download) - annotate - [select for diffs], Sun Jul 8 17:46:44 2012 UTC (11 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.23: +47 -13 lines
Diff to previous 1.23 (colored)

Split out an ask_pid() function rather than over-parameterizing the
ask_num() function. Remove now unneeded 'flags' and 'help' parameters
from both. Display out of range values in hex in ask_pid(), since
we are seeking hex input.

ok guenther@

Revision 1.23 / (download) - annotate - [select for diffs], Sun Jul 4 22:15:31 2010 UTC (13 years, 11 months ago) by halex
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.22: +3 -9 lines
Diff to previous 1.22 (colored)

make ^D handling consistant in fdisk by just bailing out instead of
returning a magic value that is not even handled as such by the caller

ok krw@

Revision 1.22 / (download) - annotate - [select for diffs], Fri Jul 24 23:28:00 2009 UTC (14 years, 10 months ago) by halex
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.21: +8 -9 lines
Diff to previous 1.21 (colored)

properly sanitize the default value in ask_num(...)

Revision 1.21 / (download) - annotate - [select for diffs], Tue Apr 7 16:06:37 2009 UTC (15 years, 1 month ago) by weingart
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.20: +7 -2 lines
Diff to previous 1.20 (colored)

Fix the default value to be between low/high range.  Thanks for
frantisek holop pointing out the issue. ok deraadt@

Revision 1.20 / (download) - annotate - [select for diffs], Mon Dec 1 20:15:35 2008 UTC (15 years, 6 months ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.19: +17 -12 lines
Diff to previous 1.19 (colored)

Back out previous; it broke specifying paritions sizes with decimals,
e.g. "0.5g".

Revision 1.19 / (download) - annotate - [select for diffs], Mon Dec 1 04:05:43 2008 UTC (15 years, 6 months ago) by ray
Branch: MAIN
Changes since 1.18: +13 -18 lines
Diff to previous 1.18 (colored)

Check for invalid integers passed getuint(); instead of getuint()
returning an error, just reprompt. If there is an error reading
from stdin, use the old (default) value.

Shrinks fdisk a few bytes!

OK deraadt.

Revision 1.18 / (download) - annotate - [select for diffs], Wed Nov 8 23:22:26 2006 UTC (17 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.17: +5 -1 lines
Diff to previous 1.17 (colored)

add a -y flag, for non-interactive use

Revision 1.17 / (download) - annotate - [select for diffs], Tue Oct 24 17:30:45 2006 UTC (17 years, 7 months ago) by moritz
Branch: MAIN
Changes since 1.16: +9 -3 lines
Diff to previous 1.16 (colored)

Check strlen(buf) to be > 0 before accessing buf[strlen(buf)-1].
OK ray@ cloder@

Revision 1.16 / (download) - annotate - [select for diffs], Mon Nov 21 01:59:24 2005 UTC (18 years, 6 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.15: +10 -7 lines
Diff to previous 1.15 (colored)

Replace default DEV_BSIZE sector conversion factor with disklabel's
sector size when possible. Fixes the "[ XX Sectors ]" size display.
Pointed out by Robert Szasz while playing with his Sony Hi-MD device.

Apply input conversion fixes similar to those recently applied to
disklabel(8). Use correct sector size in the conversions.

It is still *not* possible to use unusual sector sizes for non-ISO9660
filesystems!

ok millert@

Revision 1.15 / (download) - annotate - [select for diffs], Sat Sep 18 23:22:05 2004 UTC (19 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.14: +10 -1 lines
Diff to previous 1.14 (colored)

some delinting; ok otto

Revision 1.14 / (download) - annotate - [select for diffs], Tue Jul 29 18:38:35 2003 UTC (20 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6, OPENBSD_3_5_BASE, OPENBSD_3_5, OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (colored)

spaces

Revision 1.13 / (download) - annotate - [select for diffs], Wed Jun 11 06:22:12 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.12: +12 -32 lines
Diff to previous 1.12 (colored)

ansification

Revision 1.12 / (download) - annotate - [select for diffs], Tue Jun 3 01:13:19 2003 UTC (21 years ago) by weingart
Branch: MAIN
Changes since 1.11: +1 -6 lines
Diff to previous 1.11 (colored)

Nuke terms 3 & 4.

Revision 1.11 / (download) - annotate - [select for diffs], Sat Apr 20 00:58:32 2002 UTC (22 years, 1 month ago) by espie
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

machine/limits.h is not userland. Use limits.h
ok millert@

Revision 1.10 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:34 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.9: +2 -2 lines
Diff to previous 1.9 (colored)

Part one of userland __P removal.  Done with a simple regexp with some minor hand editing to make comments line up correctly.  Another pass is forthcoming that handles the cases that could not be done automatically.

Revision 1.9 / (download) - annotate - [select for diffs], Wed Jan 23 22:04:01 2002 UTC (22 years, 4 months ago) by mickey
Branch: MAIN
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

use sizeof instead of magic numbers

Revision 1.8 / (download) - annotate - [select for diffs], Fri Jan 18 08:38:26 2002 UTC (22 years, 4 months ago) by kjell
Branch: MAIN
Changes since 1.7: +20 -1 lines
Diff to previous 1.7 (colored)

Allow size values to be displayed in the user's choice of units.
Idea borrowed from disklabel. i.e. Users can now type "print M"
and be rewarded with partition sizes in Megs

Revision 1.7 / (download) - annotate - [select for diffs], Fri Jan 18 08:33:10 2002 UTC (22 years, 4 months ago) by kjell
Branch: MAIN
Changes since 1.6: +137 -1 lines
Diff to previous 1.6 (colored)

Add disklabel-style editing for size/offset values in
the partition tables. These values may now contain units,
such as "300k" "500M" or "2G".
(sectors, bytes, and cylinders are also supported.)
This should largely eliminate the need for a calculator
when using fdisk on large disks.

Revision 1.6 / (download) - annotate - [select for diffs], Sun Oct 19 23:30:48 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0, OPENBSD_2_9_BASE, OPENBSD_2_9, OPENBSD_2_8_BASE, OPENBSD_2_8, OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE, OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4, OPENBSD_2_3_BASE, OPENBSD_2_3, OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.5: +5 -5 lines
Diff to previous 1.5 (colored)

indent

Revision 1.5 / (download) - annotate - [select for diffs], Sun Oct 19 23:29:37 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +7 -8 lines
Diff to previous 1.4 (colored)

indent

Revision 1.4 / (download) - annotate - [select for diffs], Thu Oct 16 02:29:54 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

only help if possible

Revision 1.3 / (download) - annotate - [select for diffs], Thu Oct 16 01:47:11 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.2: +15 -6 lines
Diff to previous 1.2 (colored)

a bunch of improvements by weingart & I

Revision 1.2 / (download) - annotate - [select for diffs], Mon Sep 29 23:33:37 1997 UTC (26 years, 8 months ago) by mickey
Branch: MAIN
Changes since 1.1: +1 -2 lines
Diff to previous 1.1 (colored)

ID in the first line w/ tabs

Revision 1.1 / (download) - annotate - [select for diffs], Mon Sep 29 22:58:17 1997 UTC (26 years, 8 months ago) by weingart
Branch: MAIN

New fdisk code with interactive (command line type)
editing code.  Rewrite from the ground up, save about
20 lines of code.  Seems to create valid partition
tables on i386 and alphas.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.