aboutsummaryrefslogtreecommitdiff
path: root/sbin/bsdlabel/bsdlabel.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove deprecated GEOM classesConrad Meyer2019-08-131-35/+2
| | | | | | | | | | | | | | Follow-up on r322318 and r322319 and remove the deprecated modules. Shift some now-unused kernel files into userspace utilities that incorporate them. Remove references to removed GEOM classes in userspace utilities. Reviewed by: imp (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21249 Notes: svn path=/head/; revision=351001
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-181-1/+3
| | | | | | | | | | | | | | | | | | | | The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* Remove pc98 support completely.Yoshihiro Takahashi2017-01-281-2/+1
| | | | | | | | | I thank all developers and contributors for pc98. Relnotes: yes Notes: svn path=/head/; revision=312910
* Use NULL instead of 0 for pointers.Marcelo Araujo2016-04-181-1/+1
| | | | | | | | | | strchr(3) will return NULL if the character does not appear in the string. MFC after: 2 weeks. Notes: svn path=/head/; revision=298193
* Remove ia64.Marcel Moolenaar2014-07-071-1/+0
| | | | | | | | | | | | | | | | | | | | This includes: o All directories named *ia64* o All files named *ia64* o All ia64-specific code guarded by __ia64__ o All ia64-specific makefile logic o Mention of ia64 in comments and documentation This excludes: o Everything under contrib/ o Everything under crypto/ o sys/xen/interface o sys/sys/elf_common.h Discussed at: BSDcan Notes: svn path=/head/; revision=268351
* It seems that libdisk(3) incorrectly sets d_secperunit value.Andrey V. Elsukov2012-04-111-1/+2
| | | | | | | | | Automatically fix it like GEOM_PART_BSD does. MFC after: 1 week Notes: svn path=/head/; revision=234122
* Spelling fixes for sbin/Ulrich Spörlein2012-01-071-5/+5
| | | | Notes: svn path=/head/; revision=229778
* Replace index() and rindex() calls with strchr() and strrchr().Ed Schouten2012-01-031-2/+2
| | | | | | | | | | | | | The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls. Notes: svn path=/head/; revision=229403
* Use in-label sectorsize to determine position of the label whenMaxim Sobolev2011-12-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | writing label into a file image. The most common use - putting disklabel into ISO file. Before this change the label would always go to the offset 512, while geom_part code expects it to be in the 1st sector (i.e. 2048 incase of ISO). BSD disklabels provide good and lightweight way to logically split livecds. It is non-intrusive as far as ISO9660 goes (both boot-wise and metadata-wise) and completely transparent to anything but BSD, so you can have BSD-specific area appended after regular ISO. And with a little bit of GEOM trickery you can do even more interesting stuff with it. For example we make "hybrid" bootable CDs using this method. We create bootable ISO with kernel and such and append UFS image compressed with UZIP and it works like a charm. We put label based on the offsef of the BSD part into the ISO. The kernel boots off normal ISO9660 part, tastes label attaches it, tastes UZIP, attaches it and finally mounts UFS using GEOM_LABEL. This provides much better way of eliminating waste than doing "crunched" build. MFC after: 1 month Notes: svn path=/head/; revision=229049
* Add missing static keyword.Ed Schouten2011-12-111-1/+1
| | | | | | | | All global variables and functions are marked static. Simply because this is an enum, doesn't mean we can't do so as well. Notes: svn path=/head/; revision=228417
* Fix multi-line comment formatting.Andrey V. Elsukov2011-11-071-1/+2
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=227296
* Add recommendation to use gpart(8) when user tries write disklabelAndrey V. Elsukov2011-11-061-4/+15
| | | | | | | | | or bootcode to already opened provider. MFC after: 1 week Notes: svn path=/head/; revision=227270
* Remove unneeded checks.Andrey V. Elsukov2011-11-061-3/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=227262
* bsdlabel(8) could automatically fill many of disklabel's deprecatedAndrey V. Elsukov2011-11-061-11/+35
| | | | | | | | | | | | | | | | fields, but user could specify some of those fields when edits disklabel with `bsdlabel -e`. But without -A flag these fields might be overwritten with default values from the virgin disklabel. So, don't overwrite such fields if they are not zero. Also add checks to prevent creating disklabel with less than DEFPARTITIONS and more than MAXPARTITIONS partitions. PR: bin/162332 Tested by: Eugene Grosbein MFC after: 1 week Notes: svn path=/head/; revision=227248
* To be in sync with GEOM_PART_BSD limit the maximum number of supportedAndrey V. Elsukov2011-11-061-1/+1
| | | | | | | | | partitions to 20. MFC after: 1 week Notes: svn path=/head/; revision=227231
* Widen fields that display partition offset/length.Ulrich Spörlein2011-03-101-5/+5
| | | | | | | | | | | | | This makes partitions between 50GiB and 2TiB (16TiB for 4k drives) print correctly aligned. While here, fix type of secsize. g_sectorsize() returns ssize_t, don't store this in an unsigned var. Bump WARNS to 6. MFC after: 4 weeks Notes: svn path=/head/; revision=219449
* Remove dead code in bsdlabel depending on __alpha__Ulrich Spörlein2011-03-101-35/+1
| | | | Notes: svn path=/head/; revision=219448
* Closing file descriptors when it's doneKevin Lo2010-12-011-0/+2
| | | | Notes: svn path=/head/; revision=216095
* Fix some more warnings found by clang.Rebecca Cran2010-11-221-1/+1
| | | | Notes: svn path=/head/; revision=215704
* Don't attempt to write label with GEOM_BSD based method if the class isJaakko Heinonen2010-08-271-1/+32
| | | | | | | | | | | | | | not available. This improves error reporting when bsdlabel(8) is unable to open a device for writing. If GEOM_BSD was unavailable, only a rather obscure error message "Class not found" was printed. PR: bin/58390 Reviewed by: ae Discussed with: marcel MFC after: 1 month Notes: svn path=/head/; revision=211873
* - Check that strtoul(3) succeeds to convert the entire string in a fewJaakko Heinonen2010-08-151-7/+14
| | | | | | | | | | | places. - In getasciilabel(), set the disk type only when a valid type is given. PR: bin/86765 MFC after: 2 weeks Notes: svn path=/head/; revision=211342
* - Don't assign the return value from read(2) to a variable of typeJaakko Heinonen2010-06-301-6/+8
| | | | | | | | | | | | | int. - Use errx(3) instead of err(3) to print the error message on short reads in readlabel(). errno won't be set on short reads which can easily occur here due to the fixed size read request. PR: 144307 Reviewed by: bde Notes: svn path=/head/; revision=209614
* Use setresuid/setresgid to drop privilegesKevin Lo2010-05-161-2/+8
| | | | Notes: svn path=/head/; revision=208132
* Remove the dependency on the kernel -- in particular the gctl request toMarcel Moolenaar2009-08-191-18/+23
| | | | | | | | | | | | the GEOM_BSD class -- to translate the absolute offsets in the label to relative ones. This makes bslabel(8) work correctly with GEOM_PART and also when the BSD label is nested under arbitrary partitioning schemes. Inspired by: Eygene Ryabinkin <rea-fbsd@codelabs.ru> Approved by: re (kib) Notes: svn path=/head/; revision=196383
* - A call to close(2) might overwrite errno and thus give a wrong error messageUlf Lilleengen2008-09-301-1/+2
| | | | | | | | | | on g_providername failure. Suggested by: pjd Approved by: pjd (mentor) Notes: svn path=/head/; revision=183496
* - Improve error message given on g_providername call failure.Ulf Lilleengen2008-09-301-1/+1
| | | | | | | | | - While there, make error messages consistent with the rest. Approved by: kib (mentor) Notes: svn path=/head/; revision=183487
* - Make bsdlabel use libgeom to determine provider name, device path, the mediaUlf Lilleengen2008-09-181-22/+40
| | | | | | | | | | | | size and the sector size. - Fix a bug where bsdlabel would try to read a regular file using the geom_bsd class. Quick review by: phk Approved by: pjd (mentor) Notes: svn path=/head/; revision=183143
* Remove comment about "-r" flag from readlabel. "-r" is a no-op.Craig Rodrigues2008-03-231-1/+0
| | | | | | | | | The is comment is left over from the old disklabel command. Reviewed by: phk Notes: svn path=/head/; revision=177517
* Allow bsdlabel to operate on labels that have at most 26 partitionsMarcel Moolenaar2007-12-091-3/+5
| | | | | | | | by virtue of there not being any (lower-case) letters avaliable for more partitions. Notes: svn path=/head/; revision=174501
* o '-s' flag was killed in rev. 1.75. Clean getopt(3).Maxim Konovalov2006-10-201-1/+1
| | | | | | | | | PR: bin/104616 Submitted by: Oliver Fromme MFC after: 1 week Notes: svn path=/head/; revision=163539
* Attempt to improve the logic for automatically sizing partitionsIan Dowse2005-08-141-5/+62
| | | | | | | | | | | | | | | to take into account the new default of starting the first partition after the boot blocks instead of at sector 0. If you used automatic sizing when the first partition did not start at 0, you would get an error that the automatically sized partition extended beyond the end of the disk. Note that there are probably still many more complex cases where automatic sizing and placement will not work (e.g. non-contiguous or out of order partitions). Notes: svn path=/head/; revision=149061
* Fix the derivation of the GEOM name from the specified device name byRalf S. Engelschall2005-01-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | complementing the existing special case of a not existing /dev prefix with the recognition of an already existing /dev prefix. This implicitly solves the following two issues related to working on GEOM devices /dev/foo/bar (which have the GEOM provider name "foo/bar") with the expected commands like "bsdlabel /dev/foo/bar": 1. the error "Geom not found" when trying to write or edit the BSD label (because previously the incorrect GEOM name "bar" instead of "foo/bar" was derived from "/dev/foo/bar"). 2. the multiple times reported "magically introduced" partition offset of 63 blocks and the resulting errors like "partition extends past end of unit" and "partition c doesn't start at 0!". This implicitly resulted because bsdlabel(8) determines the "MBR offset" via GEOM and (intentionally) silently falls back to an offset of 0 if it could not be queried (which is the case if the name was incorrectly derived). Usually (at least on PCs) the offset for the first slice is 63 blocks and bsdlabel(8) automatically subtracts them from the absolute offsets in the read on-disk BSD label, resulting in the display of an effective offset of 0. If the GEOM query fails, the assumed offset of 0 is subtracted and an incorrect effective offset of 63 is displayed and tried to be worked upon. Reviewed by: pjd MFC after: 1 week Notes: svn path=/head/; revision=139856
* The disk labels generated by bsdlabel can no address more thanBrooks Davis2004-09-091-0/+3
| | | | | | | | | | | | | | 0xffffffff sectors. Document this limit and avoid installing bogus labels on disks with more sectors. Allowing the installation of labels addressing as much of the disk as possiable may be a useful addition in some situations, but this was easy to implement and should reduce confusion. PR: bin/71408 Notes: svn path=/head/; revision=134973
* The multiplier prefix is actually a multiplier suffix.Dag-Erling Smørgrav2004-08-091-1/+1
| | | | Notes: svn path=/head/; revision=133384
* Use fallthrough to simplify the multiplier logic; optimistically addDag-Erling Smørgrav2004-08-081-9/+14
| | | | | | | | support for the T multiplier; improve the error message for unrecognized multipliers. Notes: svn path=/head/; revision=133348
* Fix some whitespace issues, and move a curly brace out of an #ifdef toDag-Erling Smørgrav2004-08-081-13/+14
| | | | | | | avoid confusing auto-indenting editors. Notes: svn path=/head/; revision=133347
* Implement a '-f' flag to teach bsdlabel to work on files instead ofLuigi Rizzo2004-03-301-6/+33
| | | | | | | disk partitions. Notes: svn path=/head/; revision=127650
* When installing boot blocks into an Alpha BSD label, setup the location,John Baldwin2004-03-151-0/+10
| | | | | | | | | | | length, and flags fields at the end of the SRM boot sector so that SRM can find the bootstrap code. This fixes bsdlabel -m alpha to generate bootable disklabels. Reviewed by: phk Notes: svn path=/head/; revision=127044
* Only automatically create an 'a' partition when there is nothingPoul-Henning Kamp2003-10-181-4/+22
| | | | | | | but a 'c' partition. Notes: svn path=/head/; revision=121222
* Remove the hardcoded default block/frag/cpg values from bsdlabelIan Dowse2003-10-051-44/+5
| | | | | | | | | | | | and the logic for setting them according to the partition size. Instead, unspecified filesystem values are left at 0 so that newfs will use its own defaults. It just caused confusion to have the defaults duplicated in two different places. Reviewed by: phk Notes: svn path=/head/; revision=120821
* When we initialize a disk with a virgin label, create also an 'a'Poul-Henning Kamp2003-08-271-0/+4
| | | | | | | | partition which starts after the bootstrap area and fills the entire disk. Notes: svn path=/head/; revision=119510
* Augh! Fix the sparc64 build:Poul-Henning Kamp2003-06-071-0/+8
| | | | | | | | If we don't have a default label location for the compiled architecture, insist that a -m <architecture> option is specified. Notes: svn path=/head/; revision=115995
* Sanitize setting of labeloffset and labelsector.Poul-Henning Kamp2003-06-071-11/+4
| | | | Notes: svn path=/head/; revision=115948
* Give ia64 the exact same semantics as i386 with respect to non-512Poul-Henning Kamp2003-06-041-1/+2
| | | | | | | byte sector devices. Notes: svn path=/head/; revision=115809
* Unbreak ia64. 'nuff said.Marcel Moolenaar2003-06-041-0/+4
| | | | Notes: svn path=/head/; revision=115794
* Fix sectorsize != 512 on i386 and pc98. Add test cases for same.Poul-Henning Kamp2003-06-021-6/+19
| | | | Notes: svn path=/head/; revision=115696
* Simplify the GEOM OAM api: Drop the request type, and let everythingPoul-Henning Kamp2003-06-011-6/+6
| | | | | | | | | | | hinge on the "verb" parameter which the class gets to interpret as it sees fit. Move the entire request into the kernel and move changed parameters back when done. Notes: svn path=/head/; revision=115624
* Protext copyright[].David E. O'Brien2003-05-311-3/+2
| | | | Notes: svn path=/head/; revision=115449
* Add pc98 archtecture entry.Poul-Henning Kamp2003-05-131-0/+4
| | | | | | | Approved by: re/rwatson Notes: svn path=/head/; revision=114982
* Before reading an ascii label, initialize with defaults so thatPoul-Henning Kamp2003-05-091-0/+1
| | | | | | | | | getasciipartspec() has a sectorisize in case it needs one. Approved by: re/jhb Notes: svn path=/head/; revision=114862