summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_diskslice.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Don't attempt to copy the whole slices "struct" for DIOCGSLICEINFO.bde1998-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.
* Discussed with: bdeobrien1998-04-241-1/+1
|
* Create virgin disklabels with 8 (MAXPARTITIONS) partitions rather thanobrien1998-04-241-4/+2
| | | | | three (RAW_PART + 1); This makes ``disklabel -Brw sdN auto'' do the Right Thing.
* Add changes and code to implement a functional DEVFS.julian1998-04-191-1/+4
| | | | | | | | | | | | | | | | | | | | | This code will be turned on with the TWO options DEVFS and SLICE. (see LINT) Two labels PRE_DEVFS_SLICE and POST_DEVFS_SLICE will deliniate these changes. /dev will be automatically mounted by init (thanks phk) on bootup. See /sys/dev/slice/slice.4 for more info. All code should act the same without these options enabled. Mike Smith, Poul Henning Kamp, Soeren, and a few dozen others This code does not support the following: bad144 handling. Persistance. (My head is still hurting from the last time we discussed this) ATAPI flopies are not handled by the SLICE code yet. When this code is running, all major numbers are arbitrary and COULD be dynamically assigned. (this is not done, for POLA only) Minor numbers for disk slices ARE arbitray and dynamically assigned.
* Fixed an aliasing bug. It was too easy to defeat the check for movingbde1998-02-151-3/+13
| | | | | | or shrinking an open partition (by changing the label for a compatibility slice while partitions on the corresponding real slice are open, or vice versa).
* Make all file-system (MFS, FFS, NFS, LFS, DEVFS) related option new-style.eivind1998-01-241-1/+3
| | | | | | | | This introduce an xxxFS_BOOT for each of the rootable filesystems. (Presently not required, but encouraged to allow a smooth move of option *FS to opt_dontuse.h later.) LFS is temporarily disabled, and will be re-enabled tomorrow.
* Use ENOIOCTL instead of -1 (= ERESTART) for diskslice ioctls that arebde1997-12-061-2/+2
| | | | not handled at a particular level.
* Rename some local variables to avoid shadowing other local variables.phk1997-11-071-5/+5
| | | | Found by: -Wshadow
* Reject attempts to set an in-core label which says that the "disk"bde1997-09-161-4/+10
| | | | | | | | | | | | | | | | | | | or a partition is larger than the slice. Now `disklabel -Brw sdX auto' should fail properly on sliced disks without partition of type 165, e.g., on zip disks with the factory default formatting. Previously it set a bogus in-core label for the compatibility slice and used this to corrupt the MBR (the slice has offset 0 and size 0, but setting the label in effect corrupted its size to nonzero). `disklabel -Brw sdX auto' already failed properly on normally (not dangerously dedicated) sliced disks _with_ partition of type 165, because the compatibility slice has a nonzero offset so the MBR remained inaccessible when the size was corrupted. This bug only affected in-core labels. On-disk labels are checked carefully when they read and written.
* Removed unused #includes.bde1997-09-021-2/+1
|
* Don't include <sys/ioctl.h> in the kernel. Stage 1: don't includebde1997-03-241-2/+1
| | | | | it when it is not used. In most cases, the reasons for including it went away when the special ioctl headers became self-sufficient.
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notpeter1997-02-221-1/+1
| | | | ready for it yet.
* This is the kernel Lite/2 commit. There are some requisite userlanddyson1997-02-101-0/+1
| | | | | | | | | | | | | | | changes, so don't expect to be able to run the kernel as-is (very well) without the appropriate Lite/2 userland changes. The system boots and can mount UFS filesystems. Untested: ext2fs, msdosfs, NFS Known problems: Incorrect Berkeley ID strings in some files. Mount_std mounts will not work until the getfsent library routine is changed. Reviewed by: various people Submitted by: Jeffery Hsu <hsu@freebsd.org>
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Removed all references to b_cylinder (aka b_cylin). It was evil andbde1996-12-011-8/+1
| | | | | hasn't been used for a year or two since disksort() started sorting on b_pblkno.
* This update adds the support for != 512 byte sector SCSI devices tosos1996-12-011-1/+3
| | | | | | | | | | | | | | | | the sd & od drivers. There is also slight changes to fdisk & newfs in order to comply with different sectorsizes. Currently sectors of size 512, 1024 & 2048 are supported, the only restriction beeing in fdisk, which hunts for the sectorsize of the device. This is based on patches to od.c and the other system files by John Gumb & Barry Scott, minor changes and the sd.c patches by me. There also exist some patches for the msdos filesys code, but I havn't been able to test those (yet). John Gumb (john@talisker.demon.co.uk) Barry Scott (barry@scottb.demon.co.uk)
* Search for labels on all slices whenever any minor for a drive is opened.bde1996-10-291-44/+55
| | | | | | | | If DEVFS is configured, create devfs devices for previously invisible partitions on the slices. Fixed an old aliasing bug which caused E=17 errors from DEVFS for DIOCSDINFO when there were no real slices.
* Don't include <sys/conf.h> for the kernel in disk-related headers.bde1996-09-201-1/+2
| | | | | | | | | | It is needed for implementation details but very little of it is needed for the interface. Include it in the few places that didn't already include it. Include <sys/ioccom.h> in <sys/disklabel.h> (as already in <sys/diskslice.h>) so that all the disk-related headers are almost self-sufficient.
* dscheck() was returning without setting bp->b_error when given a negativepeter1996-08-021-1/+2
| | | | | | block number.. (assuming Debugger() returned). The disk drivers assume that dscheck() sets both error markers (bp->b_error and set B_ERROR in bp->b_flags) if it fails.
* Moved initialization of defaults for the label for the whole disk frombde1996-06-171-1/+21
| | | | | | | disklabel(8) to the kernel (dsopen()). Drivers should initialize the hardware values (rpm, interleave, skews). Drivers currently don't do this, but it usually doesn't matter since rotational position stuff is normally disabled.
* Clean up -Wunused warnings.gpalmer1996-06-121-2/+1
| | | | Reviewed by: bde
* Fixed removal of devfs entries for the real slice corresponding to thebde1996-04-191-10/+55
| | | | | | | | | compatibility slice. They were forgotten on last-close and then creating them on first-open failed. Devfs entries for slices other than the one containing the root file system are still invisible unless you open a non-devfs inode on the slice.
* Cleaned up naming and formatting in recent changes.bde1996-04-071-18/+15
|
* Fixed a bug in DEVFS code that was producing "name slot allocation failed"scrappy1996-04-051-15/+12
| | | | messages.
* changed from using dev_link() to devfs_link()scrappy1996-04-021-3/+3
|
* Convert from using dev_link() to dev_linkf()scrappy1996-04-011-15/+21
|
* Fixed group of disk devices (was wheel or games, now operator).bde1996-03-271-14/+14
| | | | | | | | | | | Added scsi control devices. Converted almost everything that I changed to use devfs_add_devswf() and verbose id macros. st.c: Renamed enrst* to erst* since that's what the current name is (enrst seems to be an old name).
* Fixed dangling pointer bugs in DIOCSDINFO.bde1996-01-281-7/+7
| | | | | Enabled DEVFS support. It doesn't work while devfs is mounted (add_devfs_devsw() doesn't work then), but seems to be safe.
* [Oops, forgot to commit this together with things that depend on it.]bde1996-01-271-11/+133
| | | | | | | | | | | First attempt at creating devfs entries for sliced devices. Doesn't quite work yet, so the heart of it is disabled. Added bdev and cdev args to dsopen(). Create devfs entries in dsopen() and (unsuccessfully) attempt to make them go away at the right times. DEVFS is #undefed at the start so that this shouldn't cause problems.
* Remove local TRUE & FALSE definitions.phk1996-01-161-5/+4
| | | | Fall into debugger on negative blk#.
OpenPOWER on IntegriCloud