OpenBSD CVS

CVS log for src/sbin/pdisk/file_media.c


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.48 / (download) - annotate - [select for diffs], Sat Jan 30 17:21:10 2016 UTC (8 years, 4 months 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, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, 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, HEAD
Changes since 1.47: +1 -2 lines
Diff to previous 1.47 (colored)

Move last three lines (#define's) from dpme.h to partition_map.h and
tweak #include's as necessary.

Revision 1.47 / (download) - annotate - [select for diffs], Sat Jan 30 17:09:11 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.46: +75 -75 lines
Diff to previous 1.46 (colored)

Fold struct dpme into struct entry. Same reasons as for folding
struct block0 into struct partition_map. Easier to read code.

Revision 1.46 / (download) - annotate - [select for diffs], Sat Jan 30 14:24:47 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.45: +5 -5 lines
Diff to previous 1.45 (colored)

There is not much to do if we run out of memory, so simply exit if
a malloc() or calloc() fails. Simplifies a bunch of logic, makes
add_data_to_map() always succeed or exit, so make it a void.

Revision 1.45 / (download) - annotate - [select for diffs], Fri Jan 29 22:51:43 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.44: +48 -46 lines
Diff to previous 1.44 (colored)

Fold struct block0 into struct partition map. There can be only one
and read/write_block0() can move the data from/to disk to/from
appropriate fields anywhere. Removes a bunch of dereferencing,
malloc'ing and pointer checking.

Revision 1.44 / (download) - annotate - [select for diffs], Thu Jan 28 13:01:33 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.43: +5 -5 lines
Diff to previous 1.43 (colored)

Use consistent 'return' idiom -- no parenthesis since that was the style
of the existing code.

Revision 1.43 / (download) - annotate - [select for diffs], Tue Jan 26 21:07:54 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.42: +4 -4 lines
Diff to previous 1.42 (colored)

dpme_name and dpme_type are NUL-terminated in Apple code, so use
strlcpy() to fill them.

They are also supposed to be NUL-padded so zap previous contents
before copying in possibly shorter new values.

Revision 1.42 / (download) - annotate - [select for diffs], Tue Jan 26 16:13:09 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.41: +3 -2 lines
Diff to previous 1.41 (colored)

Whitespace, line wrapping fixes.

Revision 1.41 / (download) - annotate - [select for diffs], Mon Jan 25 23:43:20 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.40: +8 -13 lines
Diff to previous 1.40 (colored)

Use new read/write_block0 and read/write_dpme which handle any
endian or alignment issues forcefully. Removes need for convert_*
functions so unhook convert.c from build. read/write_block become
static functions inside file_media.c.

Tweak struct block0 to stop trying to handle alignment issues by clever
declaration. Rely on the new functions to accurately translate between
on-disk and in-memory layouts.

Enables pdisk to work on amd64 and likely other architectures if
it's ever desirable. Does bring back DEV_BSIZE to pdisk.c since the
in-memory structure will *not* be 512 bytes on other archs.

Revision 1.40 / (download) - annotate - [select for diffs], Mon Jan 25 22:12:22 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.39: +301 -1 lines
Diff to previous 1.39 (colored)

Add read/write_block0 and read/write_dpme functions, not yet used.

Revision 1.39 / (download) - annotate - [select for diffs], Sat Jan 23 03:46:18 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.38: +5 -5 lines
Diff to previous 1.38 (colored)

Flip read_block() and write_block() back to taking sector addresses
instead of off_t values. Do the DEV_BSIZE multiplication in these two
functions.

Easier to read code and kills two #include <sys/param.h>.

Kill unused label.

Revision 1.38 / (download) - annotate - [select for diffs], Fri Jan 22 12:31:04 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.37: +9 -12 lines
Diff to previous 1.37 (colored)

Merge read_block() and read_file_media() into read_block(). Ditto
write_block() and write_file_media(). One layer of read/write
wrappers for pread/pwrite should be enough for anyone.

Revision 1.37 / (download) - annotate - [select for diffs], Thu Jan 21 15:33:21 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.36: +2 -45 lines
Diff to previous 1.36 (colored)

Hoist all file opening and ioctl calls into main(), passing a pointer to
a valid map to edit(). Should enable pledging a la fdisk at some point.

Since edit() always gets a valid map (and maintains its validity even when
'I'nitializing a new one) many checks for (map == NULL) are junked.

Remove some dances around block sizes by using DEV_BSIZE everywhere
since we don't support non-DEV_BSIZE (a.k.a. 512-byte) sectors.

Remove many superfluous #include statements.

Revision 1.36 / (download) - annotate - [select for diffs], Tue Jan 19 16:53:04 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.35: +1 -2 lines
Diff to previous 1.35 (colored)

Remove forward declarations for functions that do not exist.

Revision 1.35 / (download) - annotate - [select for diffs], Mon Jan 18 17:57:35 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.34: +10 -33 lines
Diff to previous 1.34 (colored)

struct file_media had 1 field left. And one place where struct
file_media was actually stored. So move the last field (fd) into
the place formerly used to store pointer to the instance. As a
result we can just pass fd's around rather than pointers to a struct
containing a fd.

close_file_media() becomes empty but for a close(). So just use
close() and nuke close_file_media().

Revision 1.34 / (download) - annotate - [select for diffs], Mon Jan 18 16:41:41 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.33: +25 -67 lines
Diff to previous 1.33 (colored)

Discard a whack of double and triple checking lseek/read/write parameters.
Just use pread/pwrite and report error emanating from them. No more
uses of size_in_byte field of struct file_media, so toss that too.

Revision 1.33 / (download) - annotate - [select for diffs], Mon Jan 18 15:30:00 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.32: +1 -22 lines
Diff to previous 1.32 (colored)

os_reload_file_media() doesn't do anything except tell you if you passed it
a NULL pointer. And the result is ignored. Nuke it. This removes the only
use of the 'regular_file' field of struct file_media. So nuke that too.

Revision 1.32 / (download) - annotate - [select for diffs], Mon Jan 18 14:55:08 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.31: +107 -107 lines
Diff to previous 1.31 (colored)

Run indent(1) over it and tweak the results a bit manually to look more
KNF'ish.

Revision 1.31 / (download) - annotate - [select for diffs], Mon Jan 18 00:04:36 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.30: +1 -17 lines
Diff to previous 1.30 (colored)

Remove a grab bag of unused #define's, fields, enum's, variables,
functions.

Revision 1.30 / (download) - annotate - [select for diffs], Sun Jan 17 23:18:19 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.29: +1 -2 lines
Diff to previous 1.29 (colored)

Change "//" comments to "/**/". Nuke really stupid ones.

Revision 1.29 / (download) - annotate - [select for diffs], Sun Jan 17 19:39:20 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.28: +2 -2 lines
Diff to previous 1.28 (colored)

Reduce namespace pollution by eliminating parameter names from forward
declarations.

Revision 1.28 / (download) - annotate - [select for diffs], Sun Jan 17 18:57:52 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.27: +1 -27 lines
Diff to previous 1.27 (colored)

Remove a bunch of ridiculous and uninformative comments like "// Defines".

Revision 1.27 / (download) - annotate - [select for diffs], Sun Jan 17 15:57:12 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.26: +9 -8 lines
Diff to previous 1.26 (colored)

Let the great de-typedef'ification begin. MEDIA -> struct file_media *.

Revision 1.26 / (download) - annotate - [select for diffs], Sat Jan 16 22:28:14 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.25: +12 -27 lines
Diff to previous 1.25 (colored)

Move last field (size_in_bytes) in struct media to struct file_media
and replace MEDIA with FILE_MEDIA everywhere. media.h becomes unused.

Revision 1.25 / (download) - annotate - [select for diffs], Sat Jan 16 22:04:20 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.24: +2 -10 lines
Diff to previous 1.24 (colored)

Oops. Missed a file.

Revision 1.24 / (download) - annotate - [select for diffs], Sat Jan 16 21:41:41 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.23: +8 -10 lines
Diff to previous 1.23 (colored)

There can be only one. 'grain' that is. i.e. DEV_BSIZE. No need to track
or store. Just use.

No functional change.

Revision 1.23 / (download) - annotate - [select for diffs], Sat Jan 16 21:29:07 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.22: +1 -19 lines
Diff to previous 1.22 (colored)

There can be only one. 'kind' that is. No need to allocate or track the
media kind since it will always be the same -- a file.

No functional change.

Revision 1.22 / (download) - annotate - [select for diffs], Sat Jan 16 20:00:50 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.21: +1 -9 lines
Diff to previous 1.21 (colored)

Start peeling away excess layers of abstraction.

Since 'file' is the only kind of media, no need to call the appropriate
functions via pointers. Just call the _file_ variants directly.
Nuke the fields do_read(), do_write(), do_close(), do_os_reload()
and the functions read_media(), write_media(), close_media() and
os_reload_media().

No functional change.

Revision 1.21 / (download) - annotate - [select for diffs], Sat Jan 16 14:49:28 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.20: +4 -5 lines
Diff to previous 1.20 (colored)

Nuke support for 1024- and 2048-byte sector devices. Error out if
anything other than 512-byte sectors are encountered. Unlink
deblock_media.c from the build.

ok jasper@

Revision 1.20 / (download) - annotate - [select for diffs], Fri Jan 15 23:16:40 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.19: +17 -40 lines
Diff to previous 1.19 (colored)

As with compute_device_size(), gut compute_block_size() and simply
ask the disklabel as everyone else does. Add file name to
compute_block_size() parameters to make error messages nicer.

Revision 1.19 / (download) - annotate - [select for diffs], Wed Jan 13 00:12:49 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.18: +1 -8 lines
Diff to previous 1.18 (colored)

Nuke unused enum.

Revision 1.18 / (download) - annotate - [select for diffs], Tue Jan 12 23:48:42 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.17: +11 -19 lines
Diff to previous 1.17 (colored)

#define LOFF_T off_t
#define llseek lseek
#define LOFF_T_MAX LLONG_MAX

I mean, really? Nuke'em and use off_t, lseek and LLONG_MAX.

Also make a couple of checks for overflow of off_t value more likely
to work.

ok millert@

Revision 1.17 / (download) - annotate - [select for diffs], Tue Jan 12 20:09:39 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.16: +5 -4 lines
Diff to previous 1.16 (colored)

Use normal err/errx/warn/warnx rather than handrolling new ones. Move
usage() to pdisk.c and nuke do_help() and '-h'.

ok jasper@ deraadt@

Revision 1.16 / (download) - annotate - [select for diffs], Tue Jan 12 16:08:37 2016 UTC (8 years, 4 months ago) by krw
Branch: MAIN
Changes since 1.15: +1 -187 lines
Diff to previous 1.15 (colored)

Remove media interation types, structures and functions. They are not used
anywhere, as evidenced by everything still compiling after they are gone.

Revision 1.15 / (download) - annotate - [select for diffs], Mon Jan 11 17:55:45 2016 UTC (8 years, 4 months ago) by jasper
Branch: MAIN
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored)

- remove some unused data structures/fields
- unifdef notdef

ok krw@

Revision 1.14 / (download) - annotate - [select for diffs], Mon Jan 11 14:27:29 2016 UTC (8 years, 4 months ago) by jasper
Branch: MAIN
Changes since 1.13: +2 -1 lines
Diff to previous 1.13 (colored)

plug a mem leak

ok krw@

Revision 1.13 / (download) - annotate - [select for diffs], Mon Jan 11 07:57:54 2016 UTC (8 years, 4 months ago) by jasper
Branch: MAIN
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (colored)

trailing whitespace

Revision 1.12 / (download) - annotate - [select for diffs], Mon Jan 11 07:54:07 2016 UTC (8 years, 4 months ago) by jasper
Branch: MAIN
Changes since 1.11: +2 -0 lines
Diff to previous 1.11 (colored)

add rcs ids

Revision 1.11 / (download) - annotate - [select for diffs], Thu Aug 20 22:02:21 2015 UTC (8 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.10: +1 -1 lines
Diff to previous 1.10 (colored)

<stdlib.h> is included, so do not need to cast result from
malloc, calloc, realloc*
ok krw millert

Revision 1.10 / (download) - annotate - [select for diffs], Tue May 25 19:01:32 2010 UTC (14 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4, 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, OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.9: +2 -1 lines
Diff to previous 1.9 (colored)

use opendev(), as requested in 6373.  document this using text borrowed from
disklabel(8), and while at it, fix the usage code to not be utterly distasteful
ok drahn

Revision 1.9 / (download) - annotate - [select for diffs], Thu May 11 17:20:40 2006 UTC (18 years ago) by martin
Branch: MAIN
CVS Tags: 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
Changes since 1.8: +0 -15 lines
Diff to previous 1.8 (colored)

remove a bunch of linux and NeXT defines and, in turn, -D__unix__

Revision 1.8 / (download) - annotate - [select for diffs], Sat Apr 29 00:43:41 2006 UTC (18 years, 1 month ago) by martin
Branch: MAIN
Changes since 1.7: +2 -51 lines
Diff to previous 1.7 (colored)

With last pdisk and full functionality for mac68k now in place, start
cleaning the maze of ifdef's not relevant for us.

This round wipes most linux and/or MacOS-only bits, more to come.

Revision 1.7 / (download) - annotate - [select for diffs], Thu Apr 27 19:52:21 2006 UTC (18 years, 1 month ago) by martin
Branch: MAIN
Changes since 1.6: +72 -38 lines
Diff to previous 1.6 (colored)

update for pdisk 0.8a2, from NetBSD, retaining our local changes;
summing it up:

- Clean up sources - fix naming, delete old email addresses
- Added support for display of Mac volume names
- Fix block 0 display to show logical offset of drivers
- Require confirmation of quit without write
- Fix iteration to not complain about missing devices
- Warn when creating/writing a map with more than 15 entries

and, most important, add do_update_dpme() which allows us to partition
OpenBSD slices without previous MacOS setup.

Tested with shared MacOS install on macppc, procedure there remains the
same.

grammer and spelling help and ok jmc@

ok miod@

Revision 1.6 / (download) - annotate - [select for diffs], Sun Apr 2 00:48:35 2006 UTC (18 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.5: +4 -4 lines
Diff to previous 1.5 (colored)

use SEEK_* for lseek()

Revision 1.5 / (download) - annotate - [select for diffs], Wed Apr 2 00:13:06 2003 UTC (21 years, 2 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, OPENBSD_3_6_BASE, OPENBSD_3_6, OPENBSD_3_5_BASE, OPENBSD_3_5, OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.4: +8 -7 lines
Diff to previous 1.4 (colored)

snprintf; drahn ok

Revision 1.4 / (download) - annotate - [select for diffs], Sun Jun 9 08:13:08 2002 UTC (21 years, 11 months ago) by todd
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.3: +27 -27 lines
Diff to previous 1.3 (colored)

rm trailing whitespace

Revision 1.3 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:37 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.2: +1 -1 lines
Diff to previous 1.2 (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.2 / (download) - annotate - [select for diffs], Sat Mar 24 00:20:59 2001 UTC (23 years, 2 months ago) by drahn
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0, OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.1: +18 -2 lines
Diff to previous 1.1 (colored)

Make the apple code compile for OpenBSD. These changes are mostly from maja.

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Sat Mar 24 00:14:06 2001 UTC (23 years, 2 months ago) by drahn
Branch: apple19980218
CVS Tags: ver1
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

Import of pdisk from apple, BSD licensed code. Archive dated Feb 18 1998 
This is a HFS partition editing tool.

Revision 1.1 / (download) - annotate - [select for diffs], Sat Mar 24 00:14:06 2001 UTC (23 years, 2 months ago) by drahn
Branch: MAIN

Initial revision

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.