summaryrefslogtreecommitdiff
path: root/sys/kern/subr_diskslice.c
Commit message (Collapse)AuthorAgeFilesLines
* Add a new ioctl for doing virgin disklabels.Jordan K. Hubbard2000-10-311-0/+34
| | | | | | | Submitted by: dillon Notes: svn path=/head/; revision=68043
* Write support for the cd(4) driver.Kenneth D. Merry2000-10-301-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows writing to DVD-RAM, PD and similar drives that probe as CD devices. Note that these are randomly writeable devices, not sequential-only devices like CD-R drives, which are supported by cdrecord. Add a new flag value for dsopen(), DSO_COMPATLABEL. The cd(4) driver now uses this flag instead of the DSO_NOLABELS flag. The DSO_NOLABELS always used a "fake" disklabel for the entire disk, provided by the caller. With the DSO_COMPATLABEL flag, dsopen() will first search the media for a label, and if it finds a label, it will use that label. Otherwise it will use the fake disklabel provided by the caller. This provides backwards compatibility, since we will still have labels for ISO9660 media. It also provides new functionality, since you can now have a regular BSD disklabel on read-only media, or on writeable media (e.g. DVD-RAM). Bruce and I both think that we should eventually (in a few years) get away from using disklabels for ISO9660 media, and just use the whole disk device (/dev/cd0). At that point disklabel handling in the cd(4) driver could follow the "normal" model, as used in the da(4) driver. Also, clean up the path in a couple of places in cdregister(). (Thanks to Nick Hibma for catching that bug.) Reviewed by: bde Notes: svn path=/head/; revision=67928
* Convert all users of fldoff() to offsetof(). fldoff() is badPoul-Henning Kamp2000-10-271-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | because it only takes a struct tag which makes it impossible to use unions, typedefs etc. Define __offsetof() in <machine/ansi.h> Define offsetof() in terms of __offsetof() in <stddef.h> and <sys/types.h> Remove myriad of local offsetof() definitions. Remove includes of <stddef.h> in kernel code. NB: Kernelcode should *never* include from /usr/include ! Make <sys/queue.h> include <machine/ansi.h> to avoid polluting the API. Deprecate <struct.h> with a warning. The warning turns into an error on 01-12-2000 and the file gets removed entirely on 01-01-2001. Paritials reviews by: various. Significant brucifications by: bde Notes: svn path=/head/; revision=67708
* Avoid the modules madness I inadvertently introduced by making thePoul-Henning Kamp2000-09-021-9/+1
| | | | | | | | | | | | | | | | | | | | | cloning infrastructure standard in kern_conf. Modules are now the same with or without devfs support. If you need to detect if devfs is present, in modules or elsewhere, check the integer variable "devfs_present". This happily removes an ugly hack from kern/vfs_conf.c. This forces a rename of the eventhandler and the standard clone helper function. Include <sys/eventhandler.h> in <sys/conf.h>: it's a helper #include like <sys/queue.h> Remove all #includes of opt_devfs.h they no longer matter. Notes: svn path=/head/; revision=65374
* Remove all traces of Julians DEVFS (incl from kern/subr_diskslice.c)Poul-Henning Kamp2000-08-201-108/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove old DEVFS support fields from dev_t. Make uid, gid & mode members of dev_t and set them in make_dev(). Use correct uid, gid & mode in make_dev in disk minilayer. Add support for registering alias names for a dev_t using the new function make_dev_alias(). These will show up as symlinks in DEVFS. Use makedev() rather than make_dev() for MFSs magic devices to prevent DEVFS from noticing this abuse. Add a field for DEVFS inode number in dev_t. Add new DEVFS in fs/devfs. Add devfs cloning to: disk minilayer (ie: ad(4), sd(4), cd(4) etc etc) md(4), tun(4), bpf(4), fd(4) If DEVFS add -d flag to /sbin/inits args to make it mount devfs. Add commented out DEVFS to GENERIC Notes: svn path=/head/; revision=64880
* Separate the struct bio related stuff out of <sys/buf.h> intoPoul-Henning Kamp2000-05-051-1/+1
| | | | | | | | | | | | | | | | | | <sys/bio.h>. <sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall not be made a nested include according to bdes teachings on the subject of nested includes. Diskdrivers and similar stuff below specfs::strategy() should no longer need to include <sys/buf.> unless they need caching of data. Still a few bogus uses of struct buf to track down. Repocopy by: peter Notes: svn path=/head/; revision=60041
* Give struct bio it's own call back mechanism.Poul-Henning Kamp2000-05-011-17/+9
| | | | Notes: svn path=/head/; revision=59840
* Remove unused variable.Matt Jacob2000-04-261-1/+0
| | | | Notes: svn path=/head/; revision=59630
* Complete the bio/buf divorce for all code below devfs::strategyPoul-Henning Kamp2000-04-151-39/+41
| | | | | | | | | | | | | Exceptions: Vinum untouched. This means that it cannot be compiled. Greg Lehey is on the case. CCD not converted yet, casts to struct buf (still safe) atapi-cd casts to struct buf to examine B_PHYS Notes: svn path=/head/; revision=59249
* Move B_ERROR flag to b_ioflags and call it BIO_ERROR.Poul-Henning Kamp2000-04-021-2/+2
| | | | | | | | | | | | | | | | (Much of this done by script) Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED. Move b_pblkno and b_iodone_chain to struct bio while we transition, they will be obsoleted once bio structs chain/stack. Add bio_queue field for struct bio aware disksort. Address a lot of stylistic issues brought up by bde. Notes: svn path=/head/; revision=58934
* Remove B_READ, B_WRITE and B_FREEBUF and replace them with a newPoul-Henning Kamp2000-03-201-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | field in struct buf: b_iocmd. The b_iocmd is enforced to have exactly one bit set. B_WRITE was bogusly defined as zero giving rise to obvious coding mistakes. Also eliminate the redundant struct buf flag B_CALL, it can just as efficiently be done by comparing b_iodone to NULL. Should you get a panic or drop into the debugger, complaining about "b_iocmd", don't continue. It is likely to write on your disk where it should have been reading. This change is a step in the direction towards a stackable BIO capability. A lot of this patch were machine generated (Thanks to style(9) compliance!) Vinum users: Greg has not had time to test this yet, be careful. Notes: svn path=/head/; revision=58345
* Fixed a memory leak for slices with an (unsupported) bad sector table.Bruce Evans2000-01-281-1/+2
| | | | | | | Broken in: rev.1.80. Notes: svn path=/head/; revision=56737
* Cleanup some more remaining bdev fluff.Poul-Henning Kamp2000-01-161-70/+18
| | | | Notes: svn path=/head/; revision=56099
* Remove BAD144 support, it has already been disabled for some time.Poul-Henning Kamp1999-12-081-77/+4
| | | | Notes: svn path=/head/; revision=54294
* Add missing 't' in printf message.Poul-Henning Kamp1999-09-251-1/+1
| | | | Notes: svn path=/head/; revision=51651
* Add a DSO_BAD144 flag which indicates that the driver actually understandPoul-Henning Kamp1999-09-201-1/+9
| | | | | | | | | | | BAD144 handling. Reject DIOCSBAD and labels with BAD144 tables if the driver cannot grok it. Reviewed by: bde Notes: svn path=/head/; revision=51467
* Const poisoning from d_name.Bruce Evans1999-09-131-6/+5
| | | | | | | Fixed some style bugs in recent changes. Notes: svn path=/head/; revision=51228
* Changes to centralise the default blocksize behaviour.Julian Elischer1999-09-091-2/+0
| | | | | | | | | More likely to follow. Submitted by: phk@freebsd.org Notes: svn path=/head/; revision=51111
* Fix a warning for the !DEVFS case.Peter Wemm1999-09-031-2/+4
| | | | Notes: svn path=/head/; revision=50856
* Revert a bunch of contraversial changes by PHK. AfterJulian Elischer1999-09-031-0/+1
| | | | | | | | | | | | | a quick think and discussion among various people some form of some of these changes will probably be recommitted. The reversion requested was requested by dg while discussions proceed. PHK has indicated that he can live with this, and it has been agreed that some form of some of these changes may return shortly after further discussion. Notes: svn path=/head/; revision=50830
* Use "multiple 4 char outdent until no wrap" rather than ANSI stringPoul-Henning Kamp1999-09-011-7/+7
| | | | | | | | | | concatenation to preserve K&R compatibility. Requested by: bde Terminology by: grog Notes: svn path=/head/; revision=50740
* Include "dscheck" and device name in all messages from dscheck().Poul-Henning Kamp1999-08-311-7/+13
| | | | Notes: svn path=/head/; revision=50712
* Make bdev userland access work like cdev userland access unlessPoul-Henning Kamp1999-08-301-1/+0
| | | | | | | | | | | | | the highly non-recommended option ALLOW_BDEV_ACCESS is used. (bdev access is evil because you don't get write errors reported.) Kill si_bsize_best before it kills Matt :-) Use the specfs routines rather having cloned copies in devfs. Notes: svn path=/head/; revision=50623
* initialize si_bsize_phys from what the drive told us.Poul-Henning Kamp1999-08-291-1/+1
| | | | Notes: svn path=/head/; revision=50550
* We don't need to pass the diskname argument all over the diskslice/labelPoul-Henning Kamp1999-08-281-35/+27
| | | | | | | code, we can find the name from any convenient dev_t Notes: svn path=/head/; revision=50511
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Convert DEVFS hooks in (most) drivers to make_dev().Poul-Henning Kamp1999-08-231-1/+5
| | | | | | | | | | | | | | | | | | | Diskslice/label code not yet handled. Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers) Add the correct hook for devfs to kern_conf.c The net result of this excercise is that a lot less files depends on DEVFS, and devtoname() gets more sensible output in many cases. A few drivers had minor additional cleanups performed relating to cdevsw registration. A few drivers don't register a cdevsw{} anymore, but only use make_dev(). Notes: svn path=/head/; revision=50254
* Spring cleaning around strategy and disklabels/slices:Poul-Henning Kamp1999-08-141-48/+18
| | | | | | | | | | | | | | | | | Introduce BUF_STRATEGY(struct buf *, int flag) macro, and use it throughout. please see comment in sys/conf.h about the flag argument. Remove strategy argument from all the diskslice/label/bad144 implementations, it should be found from the dev_t. Remove bogus and unused strategy1 routines. Remove open/close arguments from dssize(). Pick them up from dev_t. Remove unused and unfinished setgeom support from diskslice/label/bad144 code. Notes: svn path=/head/; revision=49771
* dsopen: Print a message if the unit has an invalid sector size.Greg Lehey1999-06-211-4/+6
| | | | | | | Reviewed-by: ken, bde Notes: svn path=/head/; revision=48061
* Divorce "dev_t" from the "major|minor" bitmap, which is now calledPoul-Henning Kamp1999-05-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | udev_t in the kernel but still called dev_t in userland. Provide functions to manipulate both types: major() umajor() minor() uminor() makedev() umakedev() dev2udev() udev2dev() For now they're functions, they will become in-line functions after one of the next two steps in this process. Return major/minor/makedev to macro-hood for userland. Register a name in cdevsw[] for the "filedescriptor" driver. In the kernel the udev_t appears in places where we have the major/minor number combination, (ie: a potential device: we may not have the driver nor the device), like in inodes, vattr, cdevsw registration and so on, whereas the dev_t appears where we carry around a reference to a actual device. In the future the cdevsw and the aliased-from vnode will be hung directly from the dev_t, along with up to two softc pointers for the device driver and a few houskeeping bits. This will essentially replace the current "alias" check code (same buck, bigger bang). A little stunt has been provided to try to catch places where the wrong type is being used (dev_t vs udev_t), if you see something not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if it makes a difference. If it does, please try to track it down (many hands make light work) or at least try to reproduce it as simply as possible, and describe how to do that. Without DEVT_FASCIST I belive this patch is a no-op. Stylistic/posixoid comments about the userland view of the <sys/*.h> files welcome now, from userland they now contain the end result. Next planned step: make all dev_t's refer to the same devsw[] which means convert BLK's to CHR's at the perimeter of the vnodes and other places where they enter the game (bootdev, mknod, sysctl). Notes: svn path=/head/; revision=47028
* Hack the diskslice stuff so that it allows the alpha sysinstall toDoug Rabson1999-05-091-2/+8
| | | | | | | | manipulate the disklabel. This is almost certainly not the right way to do it but I'm desperate. Notes: svn path=/head/; revision=46785
* Fix a goof in the #ifdef DEVFS case which was found by inspection,Poul-Henning Kamp1999-05-071-2/+2
| | | | | | | | it may have made things very difficult for people if they tried to used DEVFS. Notes: svn path=/head/; revision=46633
* Rename one of the two devfs_link's to devfs_makelink.Eivind Eklund1998-12-101-3/+3
| | | | Notes: svn path=/head/; revision=41658
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()Archie Cobbs1998-12-041-3/+4
| | | | | | | | | | | | | | | | | for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com> Notes: svn path=/head/; revision=41514
* Overload the correct errno for attempts to set an in-core label withBruce Evans1998-10-171-2/+2
| | | | | | | | | | | | | | | | | | a raw partition at a nonzero offset (EINVAL should have been EXDEV; DIOCSDINFO was broken, and DIOCWDINFO was broken because it depended on DIOCSDINFO). A zero offset for the raw partition should probably be enforced in setdisklabel(), and DIOCWDINFO should probably always be handled by first calling setdisklabel() so that writedisklabel() doesn't need to enforce it, but this has never been done; dsioctl() has a special check. Changes in this commit are limited to dsioctl() to preserve bug for bug compatibility in drivers that don't use the slice code (notably the ccd driver, which allows setting a bogus label in DIOCWDINFO and doesn't undo the setting when writedisklabel() fails). Notes: svn path=/head/; revision=40473
* remove bdevsw arg from dsopen();Poul-Henning Kamp1998-08-231-9/+4
| | | | | | | | Forgotten by: julian Reviewed by: bde Notes: svn path=/head/; revision=38493
* Protect all modifications to v_numoutput with splbio().Doug Rabson1998-08-131-3/+7
| | | | Notes: svn path=/head/; revision=38299
* Added a flags arg to dsopen() and updated drivers. The DSO_ONESLICEBruce Evans1998-07-301-14/+24
| | | | | | | | | | | | | | and DSO_NOLABELS flags prevent searching for slices and labels respectively. Current drivers don't set these flags. When DSO_NOLABELS is set, the in-core label for the whole disk is cloned to create an in-core label for each slice. This gives the correct result (a good in-core label for the compatibility slice) if DSO_ONESLICE is set or only one slice is found, but usually gives broken labels otherwise, so DSO_ONESLICE should be set if DSO_NOLABELS is set. Notes: svn path=/head/; revision=37974
* Centralized and optimized handling of large sectors. CentralizedBruce Evans1998-07-291-31/+74
| | | | | | | | | | checking of transfer sizes and alignments. Old version tested with 2K-sectors on od disks by: Shunsuke Akiyama <akiyama@kme.mei.co.jp>. Notes: svn path=/head/; revision=37944
* Use the slice-relative blkno in all parts of the label writeBruce Evans1998-07-291-3/+3
| | | | | | | | | protection checks. Using the partition-relative blkno in some parts broke the write protection for partitions at unusual offsets (only for partitions at offset 1 on i386's). Notes: svn path=/head/; revision=37942
* Set bp->b_resid for failed transfers in dscheck(). This is theBruce Evans1998-07-281-1/+2
| | | | | | | | | | | best place to set it, and the wd and wfd strategy routines don't set it (for failed transfers) because they expect dscheck() to initialize everything necessary. dscheck() has always set B_ERROR, but this is not quite sufficient, because b_resid is used by physio() to decide how much of a B_ERROR'ed i/o was done. Notes: svn path=/head/; revision=37925
* Initialize more defaults for the in-core label for the whole disk.Bruce Evans1998-07-201-24/+46
| | | | | | | | | | Callers only need to initialize d_secperunit now, but should initialize d_type (to reduce the IDE/SCSI confusion), d_typename (put the disk model in it) and geometry info (if it isn't completely ficticious). Callers will soon need to initialize d_secsize. Notes: svn path=/head/; revision=37781
* Cleaned up rev.1.39 - the shadowing variable should have just gone away.Bruce Evans1998-07-201-6/+4
| | | | Notes: svn path=/head/; revision=37780
* Moved allocation of the slices struct to the right place. InitializeBruce Evans1998-07-201-1/+36
| | | | | | | | everything in it (the devsw pointers were not initialized early or at all for the !DEVFS case, but this was harmless on i386's). Notes: svn path=/head/; revision=37779
* Backed out rev.1.43 (removed nonsense SLICE ifdef). SLICE isBruce Evans1998-07-201-4/+1
| | | | | | | | | | | | | normally only defined in opt_devfs.h, so testing it before including anything is normally a no-op. Undef'ing DEVFS before including opt_devfs.h is similarly useless. OTOH, DEVFS support for sliced but not SLICEd (despite defined(SLICE)) devices is either harmless (if there are no such devices, then nothing in this file is used) or necessary (otherwise). It even seems to work for sliced cd devices. Notes: svn path=/head/; revision=37777
* Fixed printf format errors.Bruce Evans1998-07-111-4/+5
| | | | Notes: svn path=/head/; revision=37555
* There is no such thing any more as "struct bdevsw".Julian Elischer1998-07-041-2/+2
| | | | | | | | | | | | | | | | | | | | | There is only cdevsw (which should be renamed in a later edit to deventry or something). cdevsw contains the union of what were in both bdevsw an cdevsw entries. The bdevsw[] table stiff exists and is a second pointer to the cdevsw entry of the device. it's major is in d_bmaj rather than d_maj. some cleanup still to happen (e.g. dsopen now gets two pointers to the same cdevsw struct instead of one to a bdevsw and one to a cdevsw). rawread()/rawwrite() went away as part of this though it's not strictly the same patch, just that it involves all the same lines in the drivers. cdroms no longer have write() entries (they did have rawwrite (?)). tapes no longer have support for bdev operations. Reviewed by: Eivind Eklund and Mike Smith Changes suggested by eivind. Notes: svn path=/head/; revision=37389
* Don't attempt to copy the whole slices "struct" for DIOCGSLICEINFO.Bruce Evans1998-06-061-2/+3
| | | | | | | | | | | | The slices "struct" isn't really a struct; we allocate only part of it in the fully dangerously dedicated case. Since the "struct" is malloced, the page beyond it may not be mapped, so attempts to copy it would crash. This problem became larger when the full struct was bloated from < 1K to > 3K by the addition of (mostly unused) DEVFS tokens some time before 2.2.0 was released. Notes: svn path=/head/; revision=36685
* Discussed with: bdeDavid E. O'Brien1998-04-241-1/+1
| | | | Notes: svn path=/head/; revision=35423
* Create virgin disklabels with 8 (MAXPARTITIONS) partitions rather thanDavid E. O'Brien1998-04-241-4/+2
| | | | | | | | three (RAW_PART + 1); This makes ``disklabel -Brw sdN auto'' do the Right Thing. Notes: svn path=/head/; revision=35422