History log of /openbsd-current/sbin/pdisk/file_media.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.48 30-Jan-2016 krw

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


# 1.47 30-Jan-2016 krw

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


# 1.46 30-Jan-2016 krw

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.


# 1.45 29-Jan-2016 krw

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.


# 1.44 28-Jan-2016 krw

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


# 1.43 26-Jan-2016 krw

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.


# 1.42 26-Jan-2016 krw

Whitespace, line wrapping fixes.


# 1.41 25-Jan-2016 krw

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.


# 1.40 25-Jan-2016 krw

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


# 1.39 23-Jan-2016 krw

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.


# 1.38 22-Jan-2016 krw

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.


# 1.37 21-Jan-2016 krw

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.


# 1.36 19-Jan-2016 krw

Remove forward declarations for functions that do not exist.


# 1.35 18-Jan-2016 krw

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().


# 1.34 18-Jan-2016 krw

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.


# 1.33 18-Jan-2016 krw

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.


# 1.32 18-Jan-2016 krw

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


# 1.31 18-Jan-2016 krw

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


# 1.30 17-Jan-2016 krw

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


# 1.29 17-Jan-2016 krw

Reduce namespace pollution by eliminating parameter names from forward
declarations.


# 1.28 17-Jan-2016 krw

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


# 1.27 17-Jan-2016 krw

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


# 1.26 16-Jan-2016 krw

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


# 1.25 16-Jan-2016 krw

Oops. Missed a file.


# 1.24 16-Jan-2016 krw

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

No functional change.


# 1.23 16-Jan-2016 krw

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.


# 1.22 16-Jan-2016 krw

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.


# 1.21 16-Jan-2016 krw

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@


# 1.20 15-Jan-2016 krw

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.


# 1.19 13-Jan-2016 krw

Nuke unused enum.


# 1.18 12-Jan-2016 krw

#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@


# 1.17 12-Jan-2016 krw

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@


# 1.16 12-Jan-2016 krw

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


# 1.15 11-Jan-2016 jasper

- remove some unused data structures/fields
- unifdef notdef

ok krw@


# 1.14 11-Jan-2016 jasper

plug a mem leak

ok krw@


# 1.13 11-Jan-2016 jasper

trailing whitespace


# 1.12 11-Jan-2016 jasper

add rcs ids


# 1.11 20-Aug-2015 deraadt

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


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.10 25-May-2010 deraadt

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 tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.9 11-May-2006 martin

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


# 1.8 29-Apr-2006 martin

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.


# 1.7 27-Apr-2006 martin

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@


# 1.6 02-Apr-2006 deraadt

use SEEK_* for lseek()


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.5 02-Apr-2003 deraadt

snprintf; drahn ok


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.4 09-Jun-2002 todd

rm trailing whitespace


Revision tags: OPENBSD_3_1_BASE
# 1.3 16-Feb-2002 millert

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 tags: OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.2 24-Mar-2001 drahn

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


# 1.1 24-Mar-2001 drahn

branches: 1.1.1;
Initial revision