summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_diskslice.c
Commit message (Collapse)AuthorAgeFilesLines
* KSE Milestone 2julian2001-09-121-2/+2
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Create a general facility for making dev_t's depend on anotherphk2001-05-261-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | dev_t. The dev_depends(dev_t, dev_t) function is for tying them to each other. When destroy_dev() is called on a dev_t, all dev_t's depending on it will also be destroyed (depth first order). Rewrite the make_dev_alias() to use this dependency facility. kern/subr_disk.c: Make the disk mini-layer use dependencies to make sure all relevant dev_t's are removed when the disk disappears. Make the disk mini-layer precreate some magic sub devices which the disk/slice/label code expects to be there. kern/subr_disklabel.c: Remove some now unneeded variables. kern/subr_diskmbr.c: Remove some ancient, commented out code. kern/subr_diskslice.c: Minor cleanup. Use name from dev_t instead of dsname()
* Don't rely on cdevsw_add() when we hack about with dev_t's.phk2001-05-241-0/+2
|
* Add a new ioctl for doing virgin disklabels.jkh2000-10-311-0/+34
| | | | Submitted by: dillon
* Write support for the cd(4) driver.ken2000-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
* Convert all users of fldoff() to offsetof(). fldoff() is badphk2000-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
* Avoid the modules madness I inadvertently introduced by making thephk2000-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.
* Remove all traces of Julians DEVFS (incl from kern/subr_diskslice.c)phk2000-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
* Separate the struct bio related stuff out of <sys/buf.h> intophk2000-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
* Give struct bio it's own call back mechanism.phk2000-05-011-17/+9
|
* Remove unused variable.mjacob2000-04-261-1/+0
|
* Complete the bio/buf divorce for all code below devfs::strategyphk2000-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
* Move B_ERROR flag to b_ioflags and call it BIO_ERROR.phk2000-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.
* Remove B_READ, B_WRITE and B_FREEBUF and replace them with a newphk2000-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.
* Fixed a memory leak for slices with an (unsupported) bad sector table.bde2000-01-281-1/+2
| | | | Broken in: rev.1.80.
* Cleanup some more remaining bdev fluff.phk2000-01-161-70/+18
|
* Remove BAD144 support, it has already been disabled for some time.phk1999-12-081-77/+4
|
* Add missing 't' in printf message.phk1999-09-251-1/+1
|
* Add a DSO_BAD144 flag which indicates that the driver actually understandphk1999-09-201-1/+9
| | | | | | | | BAD144 handling. Reject DIOCSBAD and labels with BAD144 tables if the driver cannot grok it. Reviewed by: bde
* Const poisoning from d_name.bde1999-09-131-6/+5
| | | | Fixed some style bugs in recent changes.
* Changes to centralise the default blocksize behaviour.julian1999-09-091-2/+0
| | | | | | More likely to follow. Submitted by: phk@freebsd.org
* Fix a warning for the !DEVFS case.peter1999-09-031-2/+4
|
* Revert a bunch of contraversial changes by PHK. Afterjulian1999-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.
* Use "multiple 4 char outdent until no wrap" rather than ANSI stringphk1999-09-011-7/+7
| | | | | | | concatenation to preserve K&R compatibility. Requested by: bde Terminology by: grog
* Include "dscheck" and device name in all messages from dscheck().phk1999-08-311-7/+13
|
* Make bdev userland access work like cdev userland access unlessphk1999-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.
* initialize si_bsize_phys from what the drive told us.phk1999-08-291-1/+1
|
* We don't need to pass the diskname argument all over the diskslice/labelphk1999-08-281-35/+27
| | | | code, we can find the name from any convenient dev_t
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Convert DEVFS hooks in (most) drivers to make_dev().phk1999-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().
* Spring cleaning around strategy and disklabels/slices:phk1999-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.
* dsopen: Print a message if the unit has an invalid sector size.grog1999-06-211-4/+6
| | | | Reviewed-by: ken, bde
* Divorce "dev_t" from the "major|minor" bitmap, which is now calledphk1999-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).
* Hack the diskslice stuff so that it allows the alpha sysinstall todfr1999-05-091-2/+8
| | | | | manipulate the disklabel. This is almost certainly not the right way to do it but I'm desperate.
* Fix a goof in the #ifdef DEVFS case which was found by inspection,phk1999-05-071-2/+2
| | | | | it may have made things very difficult for people if they tried to used DEVFS.
* Rename one of the two devfs_link's to devfs_makelink.eivind1998-12-101-3/+3
|
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()archie1998-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>
* Overload the correct errno for attempts to set an in-core label withbde1998-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).
* remove bdevsw arg from dsopen();phk1998-08-231-9/+4
| | | | | Forgotten by: julian Reviewed by: bde
* Protect all modifications to v_numoutput with splbio().dfr1998-08-131-3/+7
|
* Added a flags arg to dsopen() and updated drivers. The DSO_ONESLICEbde1998-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.
* Centralized and optimized handling of large sectors. Centralizedbde1998-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>.
* Use the slice-relative blkno in all parts of the label writebde1998-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).
* Set bp->b_resid for failed transfers in dscheck(). This is thebde1998-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.
* Initialize more defaults for the in-core label for the whole disk.bde1998-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.
* Cleaned up rev.1.39 - the shadowing variable should have just gone away.bde1998-07-201-6/+4
|
* Moved allocation of the slices struct to the right place. Initializebde1998-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).
* Backed out rev.1.43 (removed nonsense SLICE ifdef). SLICE isbde1998-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.
* Fixed printf format errors.bde1998-07-111-4/+5
|
* There is no such thing any more as "struct bdevsw".julian1998-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.
OpenPOWER on IntegriCloud