OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.85 / (download) - annotate - [select for diffs], Sat Mar 4 21:22:51 2023 UTC (14 months, 4 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, HEAD
Changes since 1.84: +3 -3 lines
Diff to previous 1.84 (colored)

Use nitems() in the simple iterations over mbr->mbr_prt[].

No intentional functional change.

Revision 1.84 / (download) - annotate - [select for diffs], Mon Jul 25 17:45:16 2022 UTC (22 months, 1 week ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.83: +28 -14 lines
Diff to previous 1.83 (colored)

Only MBR and GPT structures can be edited by fdisk.

If neither are found, restrict user actions to printing basic
information on the disk, reading the man page, initializing an
MBR or GPT, or terminating fdisk without changing anything.

Feedback on earlier attempt by miod@ and brynet@.

Revision 1.83 / (download) - annotate - [select for diffs], Mon Jul 18 15:06:22 2022 UTC (22 months, 2 weeks ago) by krw
Branch: MAIN
Changes since 1.82: +25 -31 lines
Diff to previous 1.82 (colored)

Synch 'help' command descriptions with man page descriptions.

Put 'setpid' description in correct place in COMMAND MODE
command list. i.e. in same order as ask_cmd() will parse
it.

Simplify ask_cmd() by displaying prompt in edit loop
rather than passing editlevel to ask_cmd().

No intentional functional change.

Revision 1.82 / (download) - annotate - [select for diffs], Sun Jul 10 20:34:31 2022 UTC (22 months, 3 weeks ago) by krw
Branch: MAIN
Changes since 1.81: +2 -2 lines
Diff to previous 1.81 (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.81 / (download) - annotate - [select for diffs], Sun Jul 10 17:46:03 2022 UTC (22 months, 3 weeks ago) by krw
Branch: MAIN
Changes since 1.80: +3 -3 lines
Diff to previous 1.80 (colored)

Use nice #define's for input buf size and output help buf size.

No functional change.

Revision 1.80 / (download) - annotate - [select for diffs], Mon Apr 18 17:32:16 2022 UTC (2 years, 1 month ago) by krw
Branch: MAIN
Changes since 1.79: +7 -8 lines
Diff to previous 1.79 (colored)

Convert the GPT header read from disk into a host-endian version,
and then back to little-endian when writing to disk.

Reduces the number of invocations of the letoh*() and htole*()
functions by 90 or so. Also makes that code much easier to read.

No intentional functional change.

Revision 1.79 / (download) - annotate - [select for diffs], Thu Oct 21 13:16:49 2021 UTC (2 years, 7 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.78: +1 -2 lines
Diff to previous 1.78 (colored)

Remove 'disk' editing command. Determining the disk geometry on startup (from
-l, -c/-h/-s or DIOCGPDINFO) should be enough for anyone.

Revision 1.78 / (download) - annotate - [select for diffs], Fri Sep 10 15:26:36 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.77: +2 -2 lines
Diff to previous 1.77 (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.77 / (download) - annotate - [select for diffs], Thu Sep 9 15:21:39 2021 UTC (2 years, 8 months ago) by krw
Branch: MAIN
Changes since 1.76: +14 -19 lines
Diff to previous 1.76 (colored)

Simplify logic in USER_edit() loop to eliminate unnecessary
goto's.

Rename CMD_SAVE to CMD_QUIT to reflect actual command (Xquit) and
help and man page verbiage.

No intentional functional change.

Revision 1.76 / (download) - annotate - [select for diffs], Wed Aug 25 23:47:36 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.75: +1 -3 lines
Diff to previous 1.75 (colored)

Two more Capt. Obvious comments go away.

Revision 1.75 / (download) - annotate - [select for diffs], Wed Aug 25 13:25:23 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.74: +33 -26 lines
Diff to previous 1.74 (colored)

Consolidate '-e' edit command parsing into ask_cmd(), simplifying
the main '-e' loop.

No functional change.

Revision 1.74 / (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.73: +9 -13 lines
Diff to previous 1.73 (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.73 / (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.72: +2 -3 lines
Diff to previous 1.72 (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.72 / (download) - annotate - [select for diffs], Thu Aug 12 17:30:52 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.71: +2 -2 lines
Diff to previous 1.71 (colored)

Oops. Lost a 'nitems()' chunk during last commit. Don't
segfault on invalid edit commands.

Revision 1.71 / (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.70: +29 -3 lines
Diff to previous 1.70 (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.70 / (download) - annotate - [select for diffs], Tue Aug 10 13:48:34 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.69: +5 -7 lines
Diff to previous 1.69 (colored)

Eliminate single use 'error' vars by directly
testing MBR_read() return value.

No intentional functional change.

Revision 1.69 / (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.68: +1 -3 lines
Diff to previous 1.68 (colored)

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

Revision 1.68 / (download) - annotate - [select for diffs], Fri Aug 6 10:41:31 2021 UTC (2 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.67: +6 -2 lines
Diff to previous 1.67 (colored)

Cleanup, clarify and generally polish the MBR/GPT initialization
code.

'-g' is promoted to be independant of '-i'. This makes it clearer
that there are four mutually exclusive initialization options.

'-i' puts the default MBR on disk, '-g' puts the default GPT on
disk, '-u' updates the MBR boot code on disk and '-A' puts a new
set of GPT partitions on disk without overwriting 'protected'
partitions.

The last initialization option specified is the one executed, so
existing '-i -g' finger memory, etc. continue to work as before.

man page/usage feedback/tweaks from jmc@

Revision 1.67 / (download) - annotate - [select for diffs], Wed Jul 21 12:22:54 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.66: +2 -2 lines
Diff to previous 1.66 (colored)

Use a dedicated struct mbr to hold the GPT protective MBR,
either the one read from disk or the default one created
when initializing GPT.

Simplifies logic, eliminates MBR_init_GPT() and demotes
MBR_protective_mbr() to a helper function called from
GPT_read().

Nuke an unused variable in passing.

No intentional functional change.

Revision 1.66 / (download) - annotate - [select for diffs], Mon Jul 19 23:24:54 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.65: +1 -10 lines
Diff to previous 1.65 (colored)

Tweak one comment and nuke a bunch of pointless ones.

Revision 1.65 / (download) - annotate - [select for diffs], Sun Jul 18 15:28:37 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.64: +7 -17 lines
Diff to previous 1.64 (colored)

Make GPT_read() obtain and validate the on-disk MBR itself, via
MBR_read(), and report success/failure.

Simplifies logic and makes clearer that the protective MBR is a
required part of a GPT.

With the standardization on 0/-1 return values for helper
functions, rename 'valid' to 'error' in GPT_read() to make logic
less mind bending.

No functional change.

Revision 1.64 / (download) - annotate - [select for diffs], Sun Jul 18 12:41:00 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.63: +3 -10 lines
Diff to previous 1.63 (colored)

Put MBR_parse() invocation inside MBR_read() instead of always
following an invocation of MBR_read() with a call to MBR_parse().

No functional change.

Revision 1.63 / (download) - annotate - [select for diffs], Tue Jul 13 15:03:34 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.62: +14 -14 lines
Diff to previous 1.62 (colored)

Disk sector addresses are normally stored/provided in uint64_t
variables/parameters, not off_t.

Adjust various parameters and variables accordingly. A few missed const's
and verbiage tweaks in passing.

No functional change.

Revision 1.62 / (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.61: +4 -4 lines
Diff to previous 1.61 (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.61 / (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.60: +6 -6 lines
Diff to previous 1.60 (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.60 / (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.59: +2 -2 lines
Diff to previous 1.59 (colored)

Add 'dk_' prefix to struct disk field names.

No functional change.

Revision 1.59 / (download) - annotate - [select for diffs], Sun Jul 11 20:51:50 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.58: +4 -4 lines
Diff to previous 1.58 (colored)

Add 'prt_' prefix to struct prt field names.

Use 'dp' instead of 'prt' for struct dos_partition *
paramters, and 'prt' instead of 'partn' for struct prt *
parameters.

No functional change.

Revision 1.58 / (download) - annotate - [select for diffs], Sun Jul 11 19:43:19 2021 UTC (2 years, 10 months ago) by krw
Branch: MAIN
Changes since 1.57: +4 -4 lines
Diff to previous 1.57 (colored)

Add 'mbr_' prefix to struct mbr field names.

Change 'offset' to mbr_lba_self and 'reloffset'
to mbr_lba_firstembr to make their use more evident.
Adjust a few parameter names to match.

Change 'part[]' to mbr_prt[] to reflect that it is an
array of struct prt.

No functional change.

Revision 1.57 / (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.56: +23 -1 lines
Diff to previous 1.56 (colored)

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

No functional change.

Revision 1.56 / (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.55: +12 -12 lines
Diff to previous 1.55 (colored)

Add tabs to make variable declarations easier
to read.

No functional change.

Revision 1.55 / (download) - annotate - [select for diffs], Sat May 15 15:20:17 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.54: +24 -16 lines
Diff to previous 1.54 (colored)

Shuffle USER_print_disk() code into a more rational, clearer
structure.

No intentional functional change.

Revision 1.54 / (download) - annotate - [select for diffs], Fri May 14 15:31:01 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.53: +7 -6 lines
Diff to previous 1.53 (colored)

Tweak the two copies of gpt_chk_mbr() to return the index of the MBR
0xEE (DOSPTYP_EFI) partition, or -1 no usable such partition is found.

Adopt a consistent idiom to capture the index for future use.

Clean up the gpt_chk_mbr() logic to make it clearer what constraints
are being applied when looking for the DOSTYP_EFI partition.

No intentional functional change.

Revision 1.53 / (download) - annotate - [select for diffs], Mon May 10 17:16:01 2021 UTC (3 years ago) by krw
Branch: MAIN
Changes since 1.52: +8 -7 lines
Diff to previous 1.52 (colored)

Replace some magic numbers with #define's. Rename GPT_get_gpt() to
GPT_read() to match MBR_read().

No intentional functional change.

Revision 1.52 / (download) - annotate - [select for diffs], Mon Apr 29 18:54:12 2019 UTC (5 years, 1 month 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
Changes since 1.51: +3 -2 lines
Diff to previous 1.51 (colored)

Add '*' to disklabel(8) editor prompt when in-memory copy of disklabel
has been modified. Use name of disk being edited in fdisk(8) editor
prompt.

Idea from tb@.

ok tb@ deraadt@

Revision 1.51 / (download) - annotate - [select for diffs], Thu Apr 26 15:55:14 2018 UTC (6 years, 1 month ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.50: +2 -2 lines
Diff to previous 1.50 (colored)

Prefer <fcntl.h> over <sys/fcntl.h> in userland
While here, delete some extra #includes and apply style(9) sort rules.

ok deraadt@ krw@ mpi@

Revision 1.50 / (download) - annotate - [select for diffs], Sat Jan 9 18:10:57 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
CVS Tags: 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.49: +3 -3 lines
Diff to previous 1.49 (colored)

Revamp the display of GPT information, hiding less important
information under the '-v' flag. This brings the GPT display more
into line with the MBR display and simplifies and hardens the parsing
of the partition info in the install scripts.

Original problem with install scripts parsing hand edited GPT
information reported by Valere Monseur via bugs@.

Man page fixes and tweaks from jmc@.
Install script changes tested & ok rpe@.

Revision 1.49 / (download) - annotate - [select for diffs], Fri Dec 11 21:57:31 2015 UTC (8 years, 5 months ago) by krw
Branch: MAIN
Changes since 1.48: +25 -8 lines
Diff to previous 1.48 (colored)

Add '-v' flag that forces the display of both GPT's and the MBR.
Useful for seeing exactly what is currently on the disk. Suggested
by a request from kettenis@.

Man page & usage ok jmc@

Revision 1.48 / (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.47: +2 -1 lines
Diff to previous 1.47 (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.47 / (download) - annotate - [select for diffs], Wed Nov 18 02:12:51 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.46: +8 -1 lines
Diff to previous 1.46 (colored)

USER_edit() (a.k.a. -e) edits the on-disk information. So zap GPT
and re-read it from disk if appropriate. i.e. when the re-read MBR
is a protective MBR.

Revision 1.46 / (download) - annotate - [select for diffs], Fri Nov 13 02:27:17 2015 UTC (8 years, 6 months ago) by krw
Branch: MAIN
Changes since 1.45: +5 -14 lines
Diff to previous 1.45 (colored)

Move from opening/closing disk for every i/o to opening the disk once
and saving the fd in the global 'disk' structure. Stop passing around
fd's and just use the global.

Makes pledge() feasible.

Prompted by and ok deraadt@

Revision 1.45 / (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.44: +26 -20 lines
Diff to previous 1.44 (colored)

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

Revision 1.44 / (download) - annotate - [select for diffs], Thu Apr 2 18:00:55 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.43: +1 -2 lines
Diff to previous 1.43 (colored)

Don't printf("offset: ...) before every call to MBR_print(). Do it
once inside MBR_print().

Revision 1.43 / (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.42: +2 -2 lines
Diff to previous 1.42 (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.42 / (download) - annotate - [select for diffs], Wed Mar 18 14:46:59 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.41: +4 -4 lines
Diff to previous 1.41 (colored)

Stop passing around little used 'struct mbr tt' parameter.  Just
make the initial mbr that tt pointed at a global that can be directly
accessed in the couple of places it is needed.

Fewer parameters, less confusion, no functional change.

Revision 1.41 / (download) - annotate - [select for diffs], Tue Mar 17 21:42:15 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.40: +3 -3 lines
Diff to previous 1.40 (colored)

Stop passing around little used and superfluous 'offset' parameter.
Just use the offset recorded/parsed in the struct mbr being used.

Can still traverse/edit extended MBRs so offset really wasn't needed.

Fewer parameters, less confusion, no functional change.

Revision 1.40 / (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.39: +10 -10 lines
Diff to previous 1.39 (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.39 / (download) - annotate - [select for diffs], Mon Mar 16 18:45:51 2015 UTC (9 years, 2 months ago) by krw
Branch: MAIN
Changes since 1.38: +1 -17 lines
Diff to previous 1.38 (colored)

Document that -i/-u are mutually exclusive and clean up the related
code a bit.

ok deraadt@ igor@ (with suggested tweak that is coming)

Revision 1.38 / (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.37: +12 -13 lines
Diff to previous 1.37 (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.37 / (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.36: +11 -20 lines
Diff to previous 1.36 (colored)

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

With the permission of Toby.

ok deraadt@

Revision 1.36 / (download) - annotate - [select for diffs], Mon Feb 9 04:27:15 2015 UTC (9 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

Rename 'm_flag' to 'e_flag' since it's '-e' that sets it. Rename
'User_modify' to 'USER_edit' for the same reason.

Revision 1.35 / (download) - annotate - [select for diffs], Mon Mar 31 22:03:29 2014 UTC (10 years, 2 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.34: +1 -3 lines
Diff to previous 1.34 (colored)

Whitespace rectification.

Revision 1.34 / (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.33: +2 -1 lines
Diff to previous 1.33 (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.33 / (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.32: +4 -4 lines
Diff to previous 1.32 (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.32 / (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.31: +2 -2 lines
Diff to previous 1.31 (colored)

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

Revision 1.31 / (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.30: +2 -2 lines
Diff to previous 1.30 (colored)

Revert last -- broke building snaps.

Revision 1.30 / (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.29: +2 -2 lines
Diff to previous 1.29 (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.29 / (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.28: +10 -14 lines
Diff to previous 1.28 (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.28 / (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.27: +8 -12 lines
Diff to previous 1.27 (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.27 / (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.26: +8 -8 lines
Diff to previous 1.26 (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.26 / (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.25: +5 -6 lines
Diff to previous 1.25 (colored)

more substantial include cleanup

Revision 1.25 / (download) - annotate - [select for diffs], Mon Feb 21 19:26:13 2011 UTC (13 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.24: +13 -7 lines
Diff to previous 1.24 (colored)

Honour MBR_read() results and don't pretend we can parse blocks we
did not successfully read. Tweak some casts.

Fixes infinite loop problem noted by jeremy@ while installing on
boxen with 'random' garbage in MBR. General loop detection may
follow post-4.9.

Tested by jeremy@ and ok miod@

Revision 1.24 / (download) - annotate - [select for diffs], Sun Feb 8 18:03:18 2009 UTC (15 years, 3 months ago) by krw
Branch: MAIN
CVS Tags: 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
Changes since 1.23: +12 -38 lines
Diff to previous 1.23 (colored)

Eliminate excessive verbiage for 'fdisk -i' and 'fdisk -u'. Especially
the multi-line banner announcing that the MBR is being changed.
Also the listing of the partition table in 'fdisk -u'. Display a
consistant message when the MBR is written.

While here cleanup and shrink code without changing any semantics.
Started with a diff posted on tech@ by Tobias Ulmer.

"I like it" marco@ ok jsing@

Revision 1.23 / (download) - annotate - [select for diffs], Thu Jul 27 04:06:13 2006 UTC (17 years, 10 months ago) by ray
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, OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.22: +13 -3 lines
Diff to previous 1.22 (colored)

Add checks to each write(2) attempt and try to keep fdisk in a
consistent state upon write failure.

OK krw@ and deraadt@.

Revision 1.22 / (download) - annotate - [select for diffs], Wed Jan 19 15:48:20 2005 UTC (19 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.21: +2 -1 lines
Diff to previous 1.21 (colored)

add a swap primitive; ok various, will be polished after by tom

Revision 1.21 / (download) - annotate - [select for diffs], Wed Jun 11 06:22:12 2003 UTC (20 years, 11 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.20: +4 -12 lines
Diff to previous 1.20 (colored)

ansification

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

Nuke terms 3 & 4.

Revision 1.19 / (download) - annotate - [select for diffs], Wed May 22 08:21:02 2002 UTC (22 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

strcpy, sprintf death; mpech ok

Revision 1.18 / (download) - annotate - [select for diffs], Fri Jan 18 08:38:26 2002 UTC (22 years, 4 months ago) by kjell
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.17: +3 -3 lines
Diff to previous 1.17 (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.17 / (download) - annotate - [select for diffs], Sat Dec 15 02:12:26 2001 UTC (22 years, 5 months ago) by kjell
Branch: MAIN
Changes since 1.16: +16 -5 lines
Diff to previous 1.16 (colored)

Get this damn diff out of my tree. ok from weingart@, deraadt@ and others.
Add a -u flag to fdisk which updates MBR code, but leaves the partition
table intact. There are still issues with 'update' having different behavior,
but I'll resolve those shortly

Revision 1.16 / (download) - annotate - [select for diffs], Mon Jan 1 21:05:34 2001 UTC (23 years, 5 months ago) by angelos
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0, OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.15: +2 -1 lines
Diff to previous 1.15 (colored)

New command "setpid", just changes the ID of a partition (no other
parameters editing) -- vassilip@dsl.cis.upenn.edu

Revision 1.15 / (download) - annotate - [select for diffs], Tue Sep 12 00:17:47 2000 UTC (23 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.14: +3 -2 lines
Diff to previous 1.14 (colored)

handle LBA extended partitions here too; scott@nts.umn.edu

Revision 1.14 / (download) - annotate - [select for diffs], Mon Sep 14 03:54:35 1998 UTC (25 years, 8 months ago) by rahnds
Branch: MAIN
CVS Tags: 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
Changes since 1.13: +5 -33 lines
Diff to previous 1.13 (colored)

Since on the powerpc, the system does not supply the user with
bios valid cyl,head,sector information (the information comes from the
sd driver) I have made some changes to fdisk to do the following.

Allow the powerpc to specify values larger than the bios limits.

All platforms now have code that will translate the LBA values
in the mbr into CHS values according to the disk geometry.
This occurs if the start and ending CHS values have been stored as
0xffffff.

If writing to the disk and one of the values of a partition violates
the bios limits, it writes the requested values in the LBA fields ,
and stores 0xffffff for the starting and ending CHS values.

This should not change the default formatting of any existing system
other than the CHS and LBA values should always match given the detected
geometry of the disk.

Revision 1.13 / (download) - annotate - [select for diffs], Tue Sep 8 11:03:16 1998 UTC (25 years, 8 months ago) by pefo
Branch: MAIN
Changes since 1.12: +10 -1 lines
Diff to previous 1.12 (colored)

For powerpc's we want to keep the preinstalled msdos partition in the init
MBR when doing a 'fdisk -i'. That is because the msdos partition is used
for booting. The OpenBSD part (part 3) is set up to be the rest of the
disk. Also the msdos partition is set as the 'active' partition.

Revision 1.12 / (download) - annotate - [select for diffs], Tue Dec 23 23:53:02 1997 UTC (26 years, 5 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3
Changes since 1.11: +3 -3 lines
Diff to previous 1.11 (colored)

swap exit and quit

Revision 1.11 / (download) - annotate - [select for diffs], Tue Oct 21 22:49:35 1997 UTC (26 years, 7 months ago) by provos
Branch: MAIN
CVS Tags: OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.10: +12 -8 lines
Diff to previous 1.10 (colored)

make fdisk grok extended partitions again. we have to keep track of the
absolute offset of the current mbr and its relative position. because:
the starting sector of the first mbr entry in an extended partition is relative
to the starting offset of the whole mbr itself. the starting offset of a new
extended partition is relative to the offset of the very first extended
partition.

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

indent

Revision 1.9 / (download) - annotate - [select for diffs], Fri Oct 17 08:07:15 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.8: +4 -1 lines
Diff to previous 1.8 (colored)

no input does not do stupid auto help

Revision 1.8 / (download) - annotate - [select for diffs], Thu Oct 16 10:35:06 1997 UTC (26 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.7: +2 -1 lines
Diff to previous 1.7 (colored)

new command: manual

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

a bunch of improvements by weingart & I

Revision 1.6 / (download) - annotate - [select for diffs], Thu Oct 2 14:58:31 1997 UTC (26 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.5: +4 -2 lines
Diff to previous 1.5 (colored)

do not whine if user quits without mods

Revision 1.5 / (download) - annotate - [select for diffs], Thu Oct 2 14:55:30 1997 UTC (26 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +2 -1 lines
Diff to previous 1.4 (colored)

tell user about "help"

Revision 1.4 / (download) - annotate - [select for diffs], Tue Sep 30 00:02:54 1997 UTC (26 years, 8 months ago) by mickey
Branch: MAIN
Changes since 1.3: +13 -7 lines
Diff to previous 1.3 (colored)

ask permission to write new MBR

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

ID in the first line w/ tabs

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

don't exseed 80 columns; bell on important warning

Revision 1.1 / (download) - annotate - [select for diffs], Mon Sep 29 22:58:19 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.