summaryrefslogtreecommitdiffstats
path: root/sbin/pdisk/file_media.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move last three lines (#define's) from dpme.h to partition_map.h andkrw2016-01-301-2/+1
| | | | tweak #include's as necessary.
* Fold struct dpme into struct entry. Same reasons as for foldingkrw2016-01-301-75/+75
| | | | struct block0 into struct partition_map. Easier to read code.
* There is not much to do if we run out of memory, so simply exit ifkrw2016-01-301-5/+5
| | | | | a malloc() or calloc() fails. Simplifies a bunch of logic, makes add_data_to_map() always succeed or exit, so make it a void.
* Fold struct block0 into struct partition map. There can be only onekrw2016-01-291-46/+48
| | | | | | 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.
* Use consistent 'return' idiom -- no parenthesis since that was the stylekrw2016-01-281-5/+5
| | | | of the existing code.
* dpme_name and dpme_type are NUL-terminated in Apple code, so usekrw2016-01-261-4/+4
| | | | | | | strlcpy() to fill them. They are also supposed to be NUL-padded so zap previous contents before copying in possibly shorter new values.
* Whitespace, line wrapping fixes.krw2016-01-261-2/+3
|
* Use new read/write_block0 and read/write_dpme which handle anykrw2016-01-251-13/+8
| | | | | | | | | | | | | | 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.
* Add read/write_block0 and read/write_dpme functions, not yet used.krw2016-01-251-1/+301
|
* Flip read_block() and write_block() back to taking sector addresseskrw2016-01-231-5/+5
| | | | | | | | | 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.
* Merge read_block() and read_file_media() into read_block(). Dittokrw2016-01-221-12/+9
| | | | | write_block() and write_file_media(). One layer of read/write wrappers for pread/pwrite should be enough for anyone.
* Hoist all file opening and ioctl calls into main(), passing a pointer tokrw2016-01-211-45/+2
| | | | | | | | | | | | 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.
* Remove forward declarations for functions that do not exist.krw2016-01-191-2/+1
|
* struct file_media had 1 field left. And one place where structkrw2016-01-181-33/+10
| | | | | | | | | | 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().
* Discard a whack of double and triple checking lseek/read/write parameters.krw2016-01-181-65/+23
| | | | | 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.
* os_reload_file_media() doesn't do anything except tell you if you passed itkrw2016-01-181-22/+1
| | | | | 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.
* Run indent(1) over it and tweak the results a bit manually to look morekrw2016-01-181-108/+108
| | | | KNF'ish.
* Remove a grab bag of unused #define's, fields, enum's, variables,krw2016-01-181-17/+1
| | | | functions.
* Change "//" comments to "/**/". Nuke really stupid ones.krw2016-01-171-2/+1
|
* Reduce namespace pollution by eliminating parameter names from forwardkrw2016-01-171-2/+2
| | | | declarations.
* Remove a bunch of ridiculous and uninformative comments like "// Defines".krw2016-01-171-27/+1
|
* Let the great de-typedef'ification begin. MEDIA -> struct file_media *.krw2016-01-171-8/+9
|
* Move last field (size_in_bytes) in struct media to struct file_mediakrw2016-01-161-27/+12
| | | | and replace MEDIA with FILE_MEDIA everywhere. media.h becomes unused.
* Oops. Missed a file.krw2016-01-161-10/+2
|
* There can be only one. 'grain' that is. i.e. DEV_BSIZE. No need to trackkrw2016-01-161-10/+8
| | | | | | or store. Just use. No functional change.
* There can be only one. 'kind' that is. No need to allocate or track thekrw2016-01-161-19/+1
| | | | | | media kind since it will always be the same -- a file. No functional change.
* Start peeling away excess layers of abstraction.krw2016-01-161-9/+1
| | | | | | | | | | 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.
* Nuke support for 1024- and 2048-byte sector devices. Error out ifkrw2016-01-161-5/+4
| | | | | | | anything other than 512-byte sectors are encountered. Unlink deblock_media.c from the build. ok jasper@
* As with compute_device_size(), gut compute_block_size() and simplykrw2016-01-151-40/+17
| | | | | ask the disklabel as everyone else does. Add file name to compute_block_size() parameters to make error messages nicer.
* Nuke unused enum.krw2016-01-131-8/+1
|
* #define LOFF_T off_tkrw2016-01-121-19/+11
| | | | | | | | | | | | #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@
* Use normal err/errx/warn/warnx rather than handrolling new ones. Movekrw2016-01-121-4/+5
| | | | | | usage() to pdisk.c and nuke do_help() and '-h'. ok jasper@ deraadt@
* Remove media interation types, structures and functions. They are not usedkrw2016-01-121-187/+1
| | | | anywhere, as evidenced by everything still compiling after they are gone.
* - remove some unused data structures/fieldsjasper2016-01-111-3/+3
| | | | | | - unifdef notdef ok krw@
* plug a mem leakjasper2016-01-111-1/+2
| | | | ok krw@
* trailing whitespacejasper2016-01-111-2/+2
|
* add rcs idsjasper2016-01-111-0/+2
|
* <stdlib.h> is included, so do not need to cast result fromderaadt2015-08-201-1/+1
| | | | | malloc, calloc, realloc* ok krw millert
* use opendev(), as requested in 6373. document this using text borrowed fromderaadt2010-05-251-1/+2
| | | | | disklabel(8), and while at it, fix the usage code to not be utterly distasteful ok drahn
* remove a bunch of linux and NeXT defines and, in turn, -D__unix__martin2006-05-111-15/+0
|
* With last pdisk and full functionality for mac68k now in place, startmartin2006-04-291-51/+2
| | | | | | cleaning the maze of ifdef's not relevant for us. This round wipes most linux and/or MacOS-only bits, more to come.
* update for pdisk 0.8a2, from NetBSD, retaining our local changes;martin2006-04-271-38/+72
| | | | | | | | | | | | | | | | | | | | | 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@
* use SEEK_* for lseek()deraadt2006-04-021-4/+4
|
* snprintf; drahn okderaadt2003-04-021-7/+8
|
* rm trailing whitespacetodd2002-06-091-27/+27
|
* 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.millert2002-02-161-1/+1
|
* Make the apple code compile for OpenBSD. These changes are mostly from maja.drahn2001-03-241-2/+18
|
* Import of pdisk from apple, BSD licensed code. Archive dated Feb 18 1998 drahn2001-03-241-0/+527
This is a HFS partition editing tool.