OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.50 / (download) - annotate - [select for diffs], Sat Mar 25 20:34:28 2023 UTC (14 months, 2 weeks ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, HEAD
Changes since 1.49: +2 -1 lines
Diff to previous 1.49 (colored)

Move LINEBUFSZ to be with its friends in misc.h.

Nuke unused HELPBUFSZ.

No functional change.

Revision 1.49 / (download) - annotate - [select for diffs], Wed Apr 20 20:43:32 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.48: +3 -2 lines
Diff to previous 1.48 (colored)

Wrap a long line.

Revision 1.48 / (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.47: +1 -3 lines
Diff to previous 1.47 (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.47 / (download) - annotate - [select for diffs], Mon Oct 25 13:51:25 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.46: +1 -6 lines
Diff to previous 1.46 (colored)

Nuke a bunch of pointless #ifndef _<.h file>/#endif guards.

Revision 1.46 / (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_0_BASE, OPENBSD_7_0
Changes since 1.45: +3 -3 lines
Diff to previous 1.45 (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.45 / (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.44: +2 -3 lines
Diff to previous 1.44 (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.44 / (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.43: +2 -1 lines
Diff to previous 1.43 (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.43 / (download) - annotate - [select for diffs], Tue Aug 24 12:55:06 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.42: +1 -2 lines
Diff to previous 1.42 (colored)

A couple more Capt. Obvious comments can go.

Revision 1.42 / (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.41: +6 -2 lines
Diff to previous 1.41 (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.41 / (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.40: +2 -2 lines
Diff to previous 1.40 (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.40 / (download) - annotate - [select for diffs], Thu Aug 12 12:31:16 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.39: +5 -1 lines
Diff to previous 1.39 (colored)

Further reduce cross-file confusion by adding USER_help() and
calling it from Xhelp(). Move declaration of struct cmd to nestle
next to its only instantiation (cmd_table) and use nitems() when
scanning cmd_table.

No functional change.

Revision 1.39 / (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.38: +7 -7 lines
Diff to previous 1.38 (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.38 / (download) - annotate - [select for diffs], Sun Jul 11 13:51:42 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.37: +1 -7 lines
Diff to previous 1.37 (colored)

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

No functional change.

Revision 1.37 / (download) - annotate - [select for diffs], Sun Jul 11 13:23:18 2021 UTC (2 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.36: +19 -19 lines
Diff to previous 1.36 (colored)

Add tabs to make struct definitions and function prototypes easier
to read.

No functional change.

Revision 1.36 / (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.35: +2 -1 lines
Diff to previous 1.35 (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.35 / (download) - annotate - [select for diffs], Thu Jun 10 15:21:19 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.34: +3 -3 lines
Diff to previous 1.34 (colored)

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

No functional change.

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

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

Revision 1.33 / (download) - annotate - [select for diffs], Sat Nov 21 16:45:41 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, 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.32: +2 -2 lines
Diff to previous 1.32 (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.32 / (download) - annotate - [select for diffs], Thu Nov 12 15:07:41 2015 UTC (8 years, 7 months ago) by krw
Branch: MAIN
Changes since 1.31: +2 -2 lines
Diff to previous 1.31 (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.31 / (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.30: +5 -2 lines
Diff to previous 1.30 (colored)

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

Revision 1.30 / (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.29: +1 -3 lines
Diff to previous 1.29 (colored)

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

Revision 1.29 / (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.28: +3 -1 lines
Diff to previous 1.28 (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.28 / (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.27: +2 -1 lines
Diff to previous 1.27 (colored)

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

Revision 1.27 / (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.26: +3 -2 lines
Diff to previous 1.26 (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.26 / (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.25: +2 -2 lines
Diff to previous 1.25 (colored)

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

Revision 1.25 / (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.24: +2 -2 lines
Diff to previous 1.24 (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.24 / (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.23: +2 -2 lines
Diff to previous 1.23 (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.23 / (download) - annotate - [select for diffs], Sat Mar 14 15:21:53 2015 UTC (9 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.22: +11 -20 lines
Diff to previous 1.22 (colored)

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

With the permission of Toby.

ok deraadt@

Revision 1.22 / (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.21: +1 -5 lines
Diff to previous 1.21 (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.21 / (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.20: +1 -11 lines
Diff to previous 1.20 (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.20 / (download) - annotate - [select for diffs], Mon Mar 10 21:40:58 2014 UTC (10 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.19: +2 -2 lines
Diff to previous 1.19 (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.19 / (download) - annotate - [select for diffs], Fri Mar 7 21:56:13 2014 UTC (10 years, 3 months ago) by krw
Branch: MAIN
Changes since 1.18: +3 -3 lines
Diff to previous 1.18 (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.18 / (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_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.17: +1 -3 lines
Diff to previous 1.17 (colored)

more substantial include cleanup

Revision 1.17 / (download) - annotate - [select for diffs], Wed Jul 11 10:27:34 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (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.16 / (download) - annotate - [select for diffs], Mon Jul 9 17:19:55 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.15: +2 -3 lines
Diff to previous 1.15 (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.15 / (download) - annotate - [select for diffs], Mon Jul 9 17:07:35 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.14: +1 -2 lines
Diff to previous 1.14 (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.14 / (download) - annotate - [select for diffs], Sun Jul 8 18:29:28 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)

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

Revision 1.13 / (download) - annotate - [select for diffs], Sun Jul 8 17:46:44 2012 UTC (11 years, 11 months ago) by krw
Branch: MAIN
Changes since 1.12: +3 -2 lines
Diff to previous 1.12 (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.12 / (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_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, OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, 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, OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.11: +3 -2 lines
Diff to previous 1.11 (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.11 / (download) - annotate - [select for diffs], Thu Sep 30 08:27:50 2004 UTC (19 years, 8 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

remove stray const, noted by david@

Revision 1.10 / (download) - annotate - [select for diffs], Sat Sep 18 23:22:05 2004 UTC (19 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.9: +3 -9 lines
Diff to previous 1.9 (colored)

some delinting; ok otto

Revision 1.9 / (download) - annotate - [select for diffs], Tue Jun 3 01:13:19 2003 UTC (21 years ago) by weingart
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.8: +1 -6 lines
Diff to previous 1.8 (colored)

Nuke terms 3 & 4.

Revision 1.8 / (download) - annotate - [select for diffs], Sun Feb 17 19:42:27 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2, OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)

Revision 1.7 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:34 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.6: +10 -10 lines
Diff to previous 1.6 (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.6 / (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.5: +19 -1 lines
Diff to previous 1.5 (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.5 / (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.4: +4 -1 lines
Diff to previous 1.4 (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.4 / (download) - annotate - [select for diffs], Sun Aug 12 12:03:01 2001 UTC (22 years, 10 months ago) by heko
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

#(endif|else) foo is incorrect, make it #endif /* foo */
deraadt@ ok

Revision 1.3 / (download) - annotate - [select for diffs], Thu Oct 16 01:47:11 1997 UTC (26 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: 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.2: +2 -2 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:38 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:18 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.