]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
10 years agoWrite sparse files by default (when SPARSE_FILE is defined).
marcel [Fri, 28 Mar 2014 01:55:02 +0000 (01:55 +0000)]
Write sparse files by default (when SPARSE_FILE is defined).
While here, detect errors when writing to stdout.

10 years agoPartitions start on cylinder boundaries.
marcel [Fri, 28 Mar 2014 01:52:48 +0000 (01:52 +0000)]
Partitions start on cylinder boundaries.

10 years agoPartitions start on track boundaries.
marcel [Fri, 28 Mar 2014 01:51:45 +0000 (01:51 +0000)]
Partitions start on track boundaries.

10 years agoPartitions start on track boundaries.
marcel [Fri, 28 Mar 2014 01:50:56 +0000 (01:50 +0000)]
Partitions start on track boundaries.

10 years agoRemove the -z flag. Let's just write a sparse file whenever we can.
marcel [Thu, 27 Mar 2014 23:44:16 +0000 (23:44 +0000)]
Remove the -z flag. Let's just write a sparse file whenever we can.

10 years agoProperly fill in d_nsectors, d_ntracks, d_ncylinders & d_secpercyl.
marcel [Thu, 27 Mar 2014 23:16:18 +0000 (23:16 +0000)]
Properly fill in d_nsectors, d_ntracks, d_ncylinders & d_secpercyl.
Round the image size to a multiple of the cyclinder size.

10 years agoRemember operator precedence?
marcel [Thu, 27 Mar 2014 23:15:07 +0000 (23:15 +0000)]
Remember operator precedence?

10 years agoGive vtoc8 a change to work: when setting the physical block size to 4K,
marcel [Thu, 27 Mar 2014 22:48:48 +0000 (22:48 +0000)]
Give vtoc8 a change to work: when setting the physical block size to 4K,
sectors/track to 8 and number or heads to 1, partitions that are block
aligned are also cyclinder aligned. With that trick, fix the vtoc8:
1.  Set physcyls, ncyls, altcyls, nheads and nsecs appropriately.
2.  Truncate the image size to exactly ncyls * nheads * nsecs * secsz.
3.  Properly write the cylinder number as the start of the partition.
4.  Oh, and actually calculate the checksum of the label...

10 years ago1. When calculating block addresses, round to the physical block
marcel [Thu, 27 Mar 2014 22:45:05 +0000 (22:45 +0000)]
1.  When calculating block addresses, round to the physical block
    size.
2.  Replace scheme_first_block() & scheme_next_block() with
    scheme_metadata(). When we round to block sizes, we can't
    reliably fixup any miscalculations.
3.  In scheme_write, calculate ncyls (number of cyclinders), based
    on the total size, sectors/track and number of heads.
4.  Add verbosity when constructing the partitions. This includes
    the starting block address and size in bytes and blocks.
5.  Add verbosity about the sectors/track and number of heads.

10 years agoRemove trksz, which was hardcoded to 1, and replace it by secs, which
marcel [Thu, 27 Mar 2014 22:39:22 +0000 (22:39 +0000)]
Remove trksz, which was hardcoded to 1, and replace it by secs, which
can be set on the command line.

10 years agoFix writing the start and size fields.
marcel [Thu, 27 Mar 2014 21:32:02 +0000 (21:32 +0000)]
Fix writing the start and size fields.

10 years ago1. Add -v option to increase vebosity levels
marcel [Thu, 27 Mar 2014 20:14:40 +0000 (20:14 +0000)]
1.  Add -v option to increase vebosity levels
2.  Fix copy-paste bug -- acrually check secsz for being a power of 2
3.  Check secsz and blksz parameters
4.  Print the sector and block size when -v is given

10 years agoAdd scheme_max_secsz() for returning the maximum sector size supported
marcel [Thu, 27 Mar 2014 20:10:26 +0000 (20:10 +0000)]
Add scheme_max_secsz() for returning the maximum sector size supported
by the partitioning scheme.

10 years agoFirst batch of media control:
marcel [Tue, 25 Mar 2014 04:45:55 +0000 (04:45 +0000)]
First batch of media control:
1.  Change -h to -H and change -t to -T. Use -H to specify the number of
    heads and -T to specify the track size (number of sectors per track).
2.  Add -S and -P. Use -S to specify the logical sector size and -P to
    specify the physical sector size.

Default to 512 for both the logical and physical sector size.
Set nheads and nsecs to 1 by default.

10 years agoMove setting CHS fields to mbr_chs() in preparation of ...
marcel [Tue, 25 Mar 2014 03:58:13 +0000 (03:58 +0000)]
Move setting CHS fields to mbr_chs() in preparation of ...

10 years agoAllow schemes to specify a maximum sector size. The minimum is fixed
marcel [Tue, 25 Mar 2014 02:32:04 +0000 (02:32 +0000)]
Allow schemes to specify a maximum sector size. The minimum is fixed
at 512. This allows checking of the sector size up-front when given
on the command line.

10 years agoMostly implement the vtoc8 scheme. The vtoc8 scheme uses cylinders for
marcel [Tue, 25 Mar 2014 02:15:19 +0000 (02:15 +0000)]
Mostly implement the vtoc8 scheme. The vtoc8 scheme uses cylinders for
the beginning of partitions, which makes it sensitive to geometry.
Again, we'll need to revisit this.

10 years agoMostly implement the pc98 scheme. The partition table has no LBA
marcel [Tue, 25 Mar 2014 00:29:56 +0000 (00:29 +0000)]
Mostly implement the pc98 scheme. The partition table has no LBA
fields at all, so we're entirely dependent upon CHS addressing.
And CHS addressing is what needs more work.

10 years agoImplement the EBR scheme. Use a function for filling in the CHS fields.
marcel [Sun, 23 Mar 2014 20:17:38 +0000 (20:17 +0000)]
Implement the EBR scheme. Use a function for filling in the CHS fields.
For now, put 0xff in each field. This needs to be revisited when we
have proper geometry. Note that even without proper CHS values, it's
already accepted by the kernel.

10 years agoAdd support for the fat32 and ebr aliases.
marcel [Sun, 23 Mar 2014 20:15:21 +0000 (20:15 +0000)]
Add support for the fat32 and ebr aliases.

10 years agoAdd the fat32 and ebr aliases. The ebr alias is needed to support
marcel [Sun, 23 Mar 2014 20:14:49 +0000 (20:14 +0000)]
Add the fat32 and ebr aliases. The ebr alias is needed to support
the EBR scheme, as it can only live inside a MBR partition of type
5 (= DOSPTYP_EXT).

10 years agoImplement the BSD scheme. This doesn't quite work as geom_part_bsd
marcel [Sun, 23 Mar 2014 19:22:13 +0000 (19:22 +0000)]
Implement the BSD scheme. This doesn't quite work as geom_part_bsd
finds an invalid label. I'm not going to worry about that right now,
because there's more to worry about: the BSD disk label has the 'c'
partition for the entire disk and we don't handle this at all.
Note also that the BSD disk label wants a geometry, so this will
have to be revisited anyway once a good solution is in place.

10 years agoImplement the APM scheme.
marcel [Sun, 23 Mar 2014 04:21:56 +0000 (04:21 +0000)]
Implement the APM scheme.

10 years agoAnd the magic number is... necessary.
marcel [Sun, 23 Mar 2014 01:17:02 +0000 (01:17 +0000)]
And the magic number is... necessary.

10 years agoRevamp:
marcel [Sun, 23 Mar 2014 01:10:05 +0000 (01:10 +0000)]
Revamp:
1.  Make secsz globally visible.
2.  Have all code use the global secsz and nparts, rather than passing
    them around.
3.  Introduce lba_t as the type to use when talking about block addresses.
4.  Work on LBAs instead of offsets. There's just too much division with
    the sector size and there's really no value to use by offsets other
    than that is what lseek() wants. For that we now have mkimg_seek().

The bigger picture is that geometry (cylinders, heads, sectors/track) and
also a possible physical sector size are to be globals that can be used
from anyway. We really don't want to pass all that stuff as arguments to
functions and then add __unused for most of them...

10 years agoFlesh-out MBR support. The CHS fields need more thought/work...
marcel [Sat, 22 Mar 2014 23:34:35 +0000 (23:34 +0000)]
Flesh-out MBR support. The CHS fields need more thought/work...

10 years agoHandle the -b option for specifying boot code that lives in the
marcel [Fri, 21 Mar 2014 19:40:05 +0000 (19:40 +0000)]
Handle the -b option for specifying boot code that lives in the
partitioning scheme's meta data. Implement it for GPT.

10 years agoAdd more partition types (mostly just the FreeBSD ones) to GPT.
marcel [Fri, 21 Mar 2014 16:11:49 +0000 (16:11 +0000)]
Add more partition types (mostly just the FreeBSD ones) to GPT.
Avoid having schemes use literal strings by introducing an enum
as the intermediate representation (see geom_part).

10 years agoUpdate usage for label support.
marcel [Fri, 21 Mar 2014 05:37:25 +0000 (05:37 +0000)]
Update usage for label support.

10 years agoAdd support for partition labels and write them for GPT.
marcel [Fri, 21 Mar 2014 05:30:27 +0000 (05:30 +0000)]
Add support for partition labels and write them for GPT.

10 years agoMake this work on big-endian architectures by adding encoding.
marcel [Fri, 21 Mar 2014 04:52:46 +0000 (04:52 +0000)]
Make this work on big-endian architectures by adding encoding.

10 years agoFix writing GPT:
marcel [Fri, 21 Mar 2014 04:14:26 +0000 (04:14 +0000)]
Fix writing GPT:
1.  Fix copy-paste bug that resulted in not sizing the image correctly
    for the secondary header and table.
2.  The hdr_lba_end field in the header is the LBA of the last usable
    sector, not the one after it.

While here, fix a white-space nit.

10 years agoDump my WIP of write support for GPT. This compiles, appears to be
marcel [Fri, 21 Mar 2014 03:27:42 +0000 (03:27 +0000)]
Dump my WIP of write support for GPT. This compiles, appears to be
complete, but isn't accepted by g_part_gpt. Time to debug and fix.

10 years agoAdd a scheme-specific write callback to write the metadata.
marcel [Thu, 20 Mar 2014 20:14:26 +0000 (20:14 +0000)]
Add a scheme-specific write callback to write the metadata.
While here:
1.  Move FreeBSD-specific headers to a more centralized place, so that
    it's easier to port mkimg.
2.  Remove inclusion of <uuid.h> where we don't need it (copy-pasted).
3.  Check the partition data given on the command line before we do any
    I/O.
4.  Add scheme_round() for rounding the partition size.
5.  Have scheme_write call the scheme-specific write callback and have
    it propagate errors back to the caller.

10 years agoReplace *_get_leader() and *_get_trailer() with a single *_metadata().
marcel [Thu, 20 Mar 2014 19:37:30 +0000 (19:37 +0000)]
Replace *_get_leader() and *_get_trailer() with a single *_metadata().
This single function takes a where argument to indicate the kind of
metadata to "size". This way we can also get rid of the "padding"
field in the scheme structure.
This should make it a little more understandable what's going on.

10 years agoCheck the partition type alias as defined by the scheme.
marcel [Thu, 20 Mar 2014 02:27:25 +0000 (02:27 +0000)]
Check the partition type alias as defined by the scheme.

10 years agoUse linker sets to provide build-time selection of the schemes
marcel [Thu, 20 Mar 2014 00:38:17 +0000 (00:38 +0000)]
Use linker sets to provide build-time selection of the schemes
that need to be supported. Each scheme provides data and callbacks
for handling the scheme-specifics.
To this end, put each scheme in its own source file.

10 years agoExpand usage(). This serves even now as a good reminder.
marcel [Wed, 19 Mar 2014 22:27:10 +0000 (22:27 +0000)]
Expand usage(). This serves even now as a good reminder.

10 years agoAdd mkimg.h. It contains the 'part' structure definition and the linked
marcel [Wed, 19 Mar 2014 21:44:51 +0000 (21:44 +0000)]
Add mkimg.h. It contains the 'part' structure definition and the linked
list (STAILQ) so that it can be shared and re-used in all source files.
Replace the now unneeded scheme_add_part() with scheme_check_part() for
posterity.

Also (should have been a separate commit), remove the enforcement of
creating a GPT table with at least 128 entries. While this is generally
advised as the default or minimum, it's not actually a hard requirement.
We now recreate a table that's precisely enough (rounded of course).

WHile

10 years agoSet BINDIR & WARNS while we're outside the source tree.
marcel [Wed, 19 Mar 2014 21:37:44 +0000 (21:37 +0000)]
Set BINDIR & WARNS while we're outside the source tree.

10 years agoNow that we can include <sys/diskpc98.h> and <sys/diskmbr.h> at
marcel [Fri, 9 Aug 2013 19:20:46 +0000 (19:20 +0000)]
Now that we can include <sys/diskpc98.h> and <sys/diskmbr.h> at
the same time withiut conflict, use the constants defined in them.

11 years agoSafe WIP: mkimg is a user-space utility for creating disk images.
marcel [Sun, 4 Aug 2013 02:37:05 +0000 (02:37 +0000)]
Safe WIP: mkimg is a user-space utility for creating disk images.
In its current form and shape, it creates images with the correct
partition contents and overall image layout. What it doesn't do
yet is actually scribble the metadata, such as partition tables
and boot code. This is where I'd like to leverage code from other
places, such as geom_part, and if possible/feasible.
Also, the utility should be a little bit smarter about files and
pipes so that we create temporary files only when needed (e.g.
when we don't know the size of a partition's contents in advance
while wrting the image to stdout).