Commit Graph

437 Commits

Author SHA1 Message Date
Gordon Tetlow
6be2e1dd37 Correct a comment. GEOM modules do not create /dev entries. They create
providers.

Pointed out by:	phk
2003-02-03 17:21:43 +00:00
Gordon Tetlow
a6fff888c3 Add the GEOM module that makes volume labels useful. A kernel compiled with
this will cause volume labels to be exposed in /dev/vol/<volname>. Currently,
there is no conflict resolution if more than one FS has the same volume name.

Reviewed by:	phk
2003-02-03 17:14:29 +00:00
Poul-Henning Kamp
ffa918814d Add a bio_disk pointer for use between geom_disk and the device drivers. 2003-02-02 11:59:54 +00:00
Poul-Henning Kamp
806d5cfff0 Eliminate the sc_openmask, ccdopen() and ccdclose() functions, we
can use the flag maintained by geom_disk.c

Having only a strategy method to intialize, don't waste space using
a cdevsw structure to do so.
2003-02-01 11:17:22 +00:00
Poul-Henning Kamp
5f6fb2dde3 Move configuration of geom/providers into its own function in preparation
for adding on-the-fly config interface.
2003-02-01 08:28:43 +00:00
Poul-Henning Kamp
a908904a1e Remove commented out g_enc_dos_partition(). We won't be needing it. 2003-01-31 21:18:41 +00:00
Poul-Henning Kamp
83dde52716 Add a rudimentary class for slicing Apple partitioned disks.
More work is needed on this, stakeholders please contact me.

Not quite asked for by:	rwatson
2003-01-31 16:27:07 +00:00
Poul-Henning Kamp
31a1093fc2 Add some agility to the disk_create() API:
Make passing the methods in a cdevsw structure optional.

Move "CANFREE" and "NOGIANT" flags into struct disk instead of the
cdevsw which may or may not be there.

Rename CANFREE to CANDELETE to match BIO_DELETE operation.

Add "OPEN" flag so drivers don't have to provide open/close methods
just to maintain such a flag.

Add temporary stopgap include of <sys/conf.h> to <sys/disk.h> until
the files which have them in the other order are fixed.

Add KASSERTS to make sure we don't get fed too many NULL pointers.

Clear our geom's softc pointer before we wither.
2003-01-30 20:34:23 +00:00
Poul-Henning Kamp
6e0b29aeca NO_GEOM cleanup: Remove sys/disklabel.h include. 2003-01-30 19:55:19 +00:00
Poul-Henning Kamp
1686ac18f9 NO_GEOM cleanup: retire disk_invalidate() 2003-01-30 19:43:50 +00:00
Poul-Henning Kamp
bf17219d59 NO_GEOM cleanup: Mark the last arg to disk_create() as unused. 2003-01-30 11:39:36 +00:00
Poul-Henning Kamp
5a67919a5e Add code to repsect the D_NOGIANT flag, should the disk device driver set it.
NO_GEOM cleanup:        remove ifdefs.

Still untested.
2003-01-29 19:47:25 +00:00
Poul-Henning Kamp
fc2b90eaab Sort these functions as the author instructed. 2003-01-29 18:37:29 +00:00
Poul-Henning Kamp
c516a05a66 Mark some args unused so this compiles in userland. 2003-01-28 09:48:09 +00:00
Poul-Henning Kamp
e55d9b0bd1 Use a void * to carry the private data for return-call'ed ioctl requests.
Amongst other things this avoids a complex workaround in the userland
regression bits.
2003-01-28 09:47:50 +00:00
Poul-Henning Kamp
7253da9c05 Implement DIOCBSDBB ioctl which overwrites first BBSIZE bytes of BSD
labeled disk.

This is complicated by the fact that BBSIZE is greater than the
PAGE_SIZE limit ioctl inflicts on arguments which are automatically
copied in.

As long as we don't need access to userland memory (copyin/out) we
can deal with the ioctl using g_callme() which executes it from the
GEOM event thread.

Once we need copyin/out, we need to return the bio with EDIRIOCTL
in order to make geom_dev call us back in the original process context
where copyin will work.

Unfortunately, that results in us getting called with Giant, so
we have to DROP_GIANT/PICKUP_GIANT around the code where we diddle
GEOMs internals.

Sometimes you just can't win...

... But it does make geom_bsd.c an almost complete example of the
GEOM beastiarium.
2003-01-26 21:54:36 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Poul-Henning Kamp
c0805171aa disk_dev_synth() is a NO_GEOM hack. 2003-01-20 11:29:07 +00:00
Poul-Henning Kamp
30f5ffb8d9 Remove need for <sys/diskslice.h> but retain numerical compatibilty just in case. 2003-01-20 11:23:00 +00:00
Poul-Henning Kamp
0f76d6d822 Finally give CCD the disk mini-layer treatment:
CAUTION:

        Previously CCD would be different from all other disks in
        the system in that there were no "ccd0" device, only a
        "ccd0c" device.

        This is no longer so after this commit.  If you access a
        ccd device through the "/dev/ccd0c" device _and_ have not
        actually put a BSD disklabel on the device, you will have
        to use the name "/dev/ccd0".  If your CCD device contains
        a BSD disklabel there should be no difference.

        You need to recompile ccdconfig(8) using the changed
        src/sys/sys/ccdvar.h for the -g "show me" option to work.

        I have run the regression test I created before I started
        overhauling CCD and it flags no problems, but this code
        is mildly evil, so take care.  If you would cry if you lost
        what's on CCD, make a back before you upgrade.

Create separate cdevsw for the /dev/ccd.ctl device.

Remove the cloning function, the disk-minilayer will do all naming
for us.

Remove the ccdunit and ccdpart functions and carry the softc pointer
in the relevant dev_t's and structures.

Release all memory when a CCD device is unconfigured, previously
the softc would linger behind.

Remove all traces of BSD disklabel fiddling code.

Remove ccdpsize, the disk mini-layer does this for us.

Don't allocate memory with M_WAITOK in ccdstrategy().

Remove boundary checks which the disk mini-layer does for us.

Don't allocate space for more than 2 ccdbuf, RAID was never implemented.

NB: I have not tried to address any of the preexisting ailments of CCD.
2003-01-19 15:00:58 +00:00
Poul-Henning Kamp
1dccd08a34 Unifdef -UDEBUG on the CCD driver. The debugging is mostly useless
and can be added back selectively, should anybody start to interest
themselves for the internal workings of ccd.

This commit will make the diffs for the following commits much more
readable.
2003-01-19 14:35:38 +00:00
Poul-Henning Kamp
e9fe7d1f7f Inline now trivial functions getccdbuf() and putccdbuf().
Fix another trivial memory-leak.
2003-01-18 12:23:49 +00:00
Poul-Henning Kamp
6b267654ab Fix minor memory-leak. 2003-01-18 11:33:06 +00:00
Poul-Henning Kamp
b51ea35631 Use the M_CCD malloc bucket instead of M_DEVBUF.
Don't keep a private freelist of a low number of trivially small structures.
2003-01-18 11:04:41 +00:00
Poul-Henning Kamp
360d71d1b5 Inline trivial function ccdintr() into its one caller ccdiodone().
Only call ccdfind() once in ccdiodone() and cache the result.
2003-01-18 10:44:17 +00:00
Poul-Henning Kamp
3b1746df8b Sanitize the copyright section a bit: We do not need two copies of the
four-clause BSD license in the file, one will do.
2003-01-18 10:08:27 +00:00
Poul-Henning Kamp
ddbf51af0c Find places to store the previously implicityly passed unit number in
the three configuration ioctls which need a unit number.

Add a "ccd.ctl" device for config operations.

Implement ioctls on ccd.ctl which rely on the explicityly passed
unit numbers.

Update ccdconfig to use the new ccd.ctl interface.

Add code to the kernel to detect old ccdconfig binaries, and whine
about it.

Add code to ccdconfig to detect old kernels, and whine about it.

These two compatibility measures will be retained only for a limited
period since they are in the way of GEOM'ification of ccd.
2003-01-17 14:53:53 +00:00
Poul-Henning Kamp
d2128d818f Add a very simple but functional GEOM mirror class.
This is committed more as an instructive tool than as a production
facility, but this will change over time.
2003-01-14 22:44:48 +00:00
Poul-Henning Kamp
d320fdbca7 Now that we have non-geom_disk based drivers, we need to cover for those,
in case they return EOPNOTSUPP on an ioctl.

Found by:	jhb
2003-01-14 21:31:00 +00:00
Poul-Henning Kamp
4b2f4ce94e Always issue ioctls as BIO_GEATTR requests. The direction of data copies on
ioctls are no reliable indication of the ioctls "set" or "get" nature or if
such simplistic categories can even be applied.

MFC candidate:	boot0cfg issue.
2003-01-13 11:34:35 +00:00
Poul-Henning Kamp
abb50a48e8 Remove g_silence(). It does not do anything anymore. 2003-01-13 08:46:32 +00:00
Poul-Henning Kamp
bf1dae82da Fix typo. 2003-01-13 08:44:03 +00:00
Poul-Henning Kamp
78b9d70000 Don't restrict MBR sectorsize to 512 bytes.
Test data provided by:	Andrey Koklin <aka@veco.ru>
2003-01-11 12:30:51 +00:00
John Baldwin
3a8790a13b Output the fstype of each partition in a disklabel in the configuration
text similar to the way that the MBR module dumps its slice types.
2003-01-10 19:44:14 +00:00
Poul-Henning Kamp
51a5c572a6 BSD disklabels expose the controling label though the 'c' partition, and
some trick is necessary to prevent further BSD geoms from attaching to
that.  Our old trick was to make sure we don't attach to a geom from
the "BSD" class, but this doesn't work if an intermediary geom obscures
this fact.  Instead, calculate the MD5 checksum of the label we target
and ask if anybody below us loves that label.  If they do we don't.

Coded by:       gordon.
2003-01-06 20:10:41 +00:00
Poul-Henning Kamp
72384683ad In userland case include <errno.h>, not <err.h>. This is needed to make
the src/tools/regression/geom stuff compile.
2003-01-06 20:05:45 +00:00
Yoshihiro Takahashi
404a379e4a Rename the dos_partition structure for pc98 to pc98_partition. 2003-01-04 08:50:48 +00:00
Poul-Henning Kamp
f05f44f0f2 Remove CCDF_SWAP and CCDF_PARITY, they have never been implemented. 2003-01-03 08:57:40 +00:00
Yoshihiro Takahashi
05f0a5a323 MFMBR: Add ioctls for writing an IPL and a boot menu. 2003-01-03 07:13:36 +00:00
Poul-Henning Kamp
d616ee081f Remove unused second argument from BIO_STRATEGY() 2003-01-03 05:51:11 +00:00
Poul-Henning Kamp
acb161b16f Optimize the size of the work-items by letting the mapping function
decide the largest size which stays inside the zone and does not
collide with a lock sector.
2003-01-02 19:29:49 +00:00
Poul-Henning Kamp
105df8c3d7 Update si_bsize_phys on open.
MFC candidate.
2003-01-02 09:38:22 +00:00
Jens Schweikhardt
d64ada501a Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.
2002-12-30 21:18:15 +00:00
Poul-Henning Kamp
f8cfa0dbaf Implement ioctls for tampering with sector0. 2002-12-29 14:59:24 +00:00
Poul-Henning Kamp
9693da433c Remove the "ascii" attribute from the sysctls so that "sysctl -a" will
skip them.
2002-12-27 07:58:59 +00:00
Poul-Henning Kamp
5ab413bf6e white-space changes 2002-12-26 21:02:50 +00:00
Poul-Henning Kamp
3ff81a4ca8 Use a mutex assert to document our locking circumstances. 2002-12-26 20:48:22 +00:00
Poul-Henning Kamp
4fbfd368dd We should not need to hold Giant for sbuf operations any more. 2002-12-26 20:46:30 +00:00
Poul-Henning Kamp
cd4b1352fa Add an XXX comment to explain the predicament. 2002-12-26 20:45:37 +00:00
Poul-Henning Kamp
cea573842c Don't forget our topology lock in the MBREXT case. 2002-12-19 12:01:19 +00:00
Poul-Henning Kamp
1e90b74683 Solve another bug in the mapping code: correctly skip lock sectors.
Make sure sector zero is protected if it contains metadata.

Lower WARNS for gbde to 3 on non-i386 archs.  rijndael-fst is evil
but appearntly does the right thing and passes the test-vectors.

MFC Candidate.
2002-12-18 22:11:54 +00:00
Poul-Henning Kamp
88806cc28c Fix two blunders in the mapping functions which can lead to corrupt data,
for request sizes larger than the sectorsize or for multi-key setups.

See warning mailed to current@ for details of recovery.

Found by:	Marcus Reid <marcus@blazingdot.com>
2002-12-18 19:57:27 +00:00
Poul-Henning Kamp
0ae8896ed2 Balk at unaligned requests.
MFC candidate.
2002-12-18 19:53:59 +00:00
Poul-Henning Kamp
9eebd265b9 Add a check for negative offset locations and return EINVAL for them. 2002-12-17 21:31:58 +00:00
Poul-Henning Kamp
dd0879a966 Don't mangle geometry for pc98, this will happen in the ata driver. 2002-12-17 15:50:51 +00:00
Poul-Henning Kamp
50bd488da3 Remember to hold topology lock when we change things.
Spotted by:	kuriyama
2002-12-17 09:44:10 +00:00
Poul-Henning Kamp
2cc40a38a8 Constify the dumpconf() function. 2002-12-17 07:22:48 +00:00
Poul-Henning Kamp
a1d5f791fa Get rid of g_slice_addslice() and use g_slice_config() instead.
Tested with:	i386 + src/tools/regression/geom
2002-12-16 23:08:48 +00:00
Poul-Henning Kamp
0f9d3dba37 Constification and some s/int/u_int/ changes. 2002-12-16 22:33:27 +00:00
Poul-Henning Kamp
cc0163a3c4 Add a couple of KASSERTS, just in case. 2002-12-13 22:04:45 +00:00
Poul-Henning Kamp
821a4d01ea Don't interpret the hotspots relative to all slices on a slicer, but
relative to the parent device.
2002-12-13 21:31:13 +00:00
Poul-Henning Kamp
ef7b370b00 Fix spelling in comment. 2002-12-13 21:10:59 +00:00
Søren Schmidt
8ba4488cea Add support for the PC98 platform to the ATA driver.
This mostly consists of functionality to serialize accesses to
the two ATA channels (which can also be used to "fix" certain
PCI based controllers).
Add support for Acard controllers.
Enable the ATA driver in PC98 GENERIC, and add device hints.
Update man page with latest support.

The PC98 core team has kindly provided me with a PC98
machine that made this all possible, thanks to all that
contributed to that effort, without that this would
probably newer have been possible..

Approved by: re@
2002-12-03 20:20:44 +00:00
Poul-Henning Kamp
00e11500e2 Use the hotspot code to prevent people from overwriting their disklabel
with stuff which would ruin the day for any open parititons.

Approved by:	re
2002-12-02 20:23:54 +00:00
Poul-Henning Kamp
188321b737 Add a simplified version of the hot-spot code to enable us to protect
in-band disklabels from in-band vandalism.

Approve by:	re
2002-12-02 19:59:25 +00:00
Poul-Henning Kamp
c7f74a4931 Use more mnemonic argument names in the access functions.
Sponsored by:	DARPA & NAI Labs
Approved by:	re (blanket)
2002-12-01 15:54:39 +00:00
Poul-Henning Kamp
f03692cba5 Fix a cut&past-o.
Spotted by:	yar
Approved by:	re (blanket)
2002-12-01 15:53:31 +00:00
Poul-Henning Kamp
19c61e97fb Conceiveably, there may exist an algorithm which can tell if a sequence of bytes
are the output of AES/128/CBC or ARC4RANDOM.  Encrypt the random data with which
we wipe when we get a BIO_DELETE to make such an algorithm useful.

Sponsored by:	DARPA & NAI Labs
Approved by:	re (blanket)
2002-12-01 15:50:48 +00:00
Poul-Henning Kamp
3a4c5955ce Use unsigned for an index.
Sponsored by:	DARPA & NAI Labs.
Approved by:	re (blanket).
2002-12-01 15:47:49 +00:00
Poul-Henning Kamp
534de7e11d Remember to update the providers idea of its size when we reconfigure
a slice child.

Approved by:	re
2002-11-20 20:12:52 +00:00
Poul-Henning Kamp
82e5a9a354 Do not call the dumpconf method unless there is one.
Compare pointers with NULL.

Partially submitted by:	Christian Carstensen <cc@gate5.de>
Approved by:	re
2002-11-20 18:10:42 +00:00
Yoshihiro Takahashi
8a529159ad Save a slice name on the disk and print it at g_pc98_dumpconf(). 2002-11-17 13:56:37 +00:00
Poul-Henning Kamp
11af41920e Remove harmless but irritating printf. 2002-11-08 15:35:16 +00:00
Poul-Henning Kamp
749cefac1b Always recalculate the SRM checksum if the label is at 64 bytes offset.
Tested by:	jhb
2002-11-08 15:31:34 +00:00
Yoshihiro Takahashi
962cf6f7bb Fix to support pc98.
It is mostly merged from MBR specific part.

Reviewed by:	phk
2002-11-07 16:42:37 +00:00
Poul-Henning Kamp
e6e142398f Straighten up the geom.ctl config interface definitions.
Sponsored by:	DARPA & NAI Labs
2002-11-06 20:05:15 +00:00
Poul-Henning Kamp
a9ed5e1173 Polish a bit here and there.
Reenable the geom.ctl device so people can play with gbde.

Sponsored by:	DARPA & NAI Labs
2002-11-04 09:31:02 +00:00
Poul-Henning Kamp
5afa461402 Run a revision on the GBDE encryption facility.
Replace ARC4 with SHA2-512.
Change lock-structure encoding to use random ordering rather for obscurity.
Encrypt lock-structure with AES/256 instead of AES/128.
Change kkey derivation to be MD5 hash based.
Watch for malloc(M_NOWAIT) failures and ditch our cache when they happen.
Remove clause 3 of the license with NAI Labs consent.

Many thanks to "Lucky Green" <shamrock@cypherpunks.to> and "David
Wagner" <daw@cs.berkeley.edu>, for code reading, inputs and
suggestions.

This code has still not been stared at for 10 years by a gang of
hard-core cryptographers.  Discretion advised.

NB: These changes result in the on-disk format changing: dump/restore needed.

Sponsored by:   DARPA & NAI Labs.
2002-11-04 09:27:01 +00:00
Poul-Henning Kamp
4b787a3959 Reject slices where begin == end.
Remove clause 3 from the license with NAI Labs consent.

Sponsored by:	DARPA & NAI Labs
2002-11-04 06:30:38 +00:00
Poul-Henning Kamp
a5b0a0ca37 Remove clause 3 in the license with NAI's consent.
Reject slices with type==0.
Diddle the bootverbose printfs.

Sponsored by:	DARPA & NAI Labs
2002-11-04 06:29:05 +00:00
Marcel Moolenaar
23280b373b Remove the GEOM_GPT hack. We now check for partition type 0xEE and
skip those. This handles the Protective MBR (PMBR) which consists
of a single partition of type 0xEE that covers the whole disk and
as such protects the GPT partitioning. We allow other partitions to
be present besides partitions of type 0xEE and as such interpret
partition type 0xEE as a "hands-off" partition only.

While here, fix g_mbrext_dumpconf to test if indent is NULL and
dump the data in a form that libdisk can grok. Change the logic
in g_mbr_dumpconf to match that of g_mbrext_dumpconf. This does
not change the output, but prevents a NULL-pointer dereference
when indent == NULL && pp == NULL.
2002-11-02 12:01:12 +00:00
Marcel Moolenaar
0df5787813 Fix dumpconf so libdisk can grok its output. We weren't checking
if indent was NULL. Consequently we always emitted the XML format.
2002-11-02 11:45:54 +00:00
Poul-Henning Kamp
3432e4fd03 malloc(9) with M_NOWAIT seems to return NULL a lot more than I would have
expected under -current.  This is a problem for GEOM because the up/down
threads cannot sleep waiting for memory to become free.  The reason they
cannot sleep is that paging things out to disk may be the only way we can
clear up some RAM.  Nice catch-22 there.

Implement a rudimentary ENOMEM recovery strategy:  If an I/O request
fails with an error code of ENOMEM, schedule it for a retry, and
tell the down-thread to sleep hz/10 to get other parts of the system
a chance to free up some memory, in particular the up-path in GEOM.

All caches should probably start to monitor malloc(9) failures using the new
malloc_last_fail() function, and release when it indicates congestion.

Sponsored by:	DARPA & NAI Labs.
2002-11-02 11:08:07 +00:00
Poul-Henning Kamp
5274973ae2 Make this compile in the userland shims again.
Sponsored by:	DARPA & NAI Labs
2002-11-01 15:57:55 +00:00
Poul-Henning Kamp
b630d83f28 Add KASSERT for bio_cmd validity here as well. Various hacks still
bypass specfs.
2002-11-01 15:56:26 +00:00
Poul-Henning Kamp
bfccaa1df2 Spruce up bootverbose output a bit.
Allow extended partitions to have flag=0x80
2002-10-31 22:18:49 +00:00
Poul-Henning Kamp
6c4a970782 Change the kkey generation cherry-picker to use MD5.
Sponsored by:	DARPA & NAI Labs
2002-10-30 22:13:54 +00:00
Poul-Henning Kamp
d518e53936 Add the remaning part of the new libdisk interaction.
WARNING:  This is not a published interface, it is a stopgap measure for
WARNING:  libdisk so we can get 5.0-R out of the door.

Sponsored by:	DARPA & NAI Labs
2002-10-28 22:43:54 +00:00
Poul-Henning Kamp
89f4551e95 Add support for the new libdisk interaction.
Sponsored by:	DARPA & NAI Labs.
2002-10-28 22:42:20 +00:00
Poul-Henning Kamp
1907a57b5f Fix a bug in the cherry-picker kkey generator routine.
WARNING:  You need to backup and restore the _unencrypted_ contents
WARNING:  of your GBDE disks when you take this update!

Sponsored by:	DARPA & NAI Labs.
2002-10-28 11:06:58 +00:00
Poul-Henning Kamp
8c847e9020 Add more compatibility junk. 2002-10-28 07:50:47 +00:00
Poul-Henning Kamp
b2758b2f23 Don't truncate on large disks. 2002-10-27 10:17:38 +00:00
Poul-Henning Kamp
077f9aa12e Make geom_mbr.c optional on PC98, use GEOM_MBR option to include it.
Disable check for supposedly magic "IPL1" string for PC98 labels, its
thaumaturgical power is in doubt.
2002-10-26 20:17:59 +00:00
Poul-Henning Kamp
3d5500fc51 Reduce the GEOM verbosity under bootverbose to something more sufferable.
This is not quite the set of information I would want, but the tree where
I have the "correct" version is messed up with conflicts.

Sponsored by:	DARPA & NAI Labs.
2002-10-25 20:09:45 +00:00
Poul-Henning Kamp
ce225127b9 Add a g_dev_print() function which prints all the /dev entries GEOM
know about.
2002-10-25 18:42:42 +00:00
Poul-Henning Kamp
c03bf4f225 Loose the g_dev_clone() noise. 2002-10-25 17:00:15 +00:00
Poul-Henning Kamp
ed1ebb9691 Use a better test to prevent tasting geom.ctl so we don't screw the
regression tests.
2002-10-24 21:32:49 +00:00
Poul-Henning Kamp
d3eaf40966 Don't taste the first provider, it's /dev/geom.ctl and it's not going
to taste like anything we like anyway.
2002-10-24 19:20:28 +00:00
Poul-Henning Kamp
6adb748875 No need to specify CTLTYPE_INT when we use SYSCTL_INT. 2002-10-20 22:46:50 +00:00
Poul-Henning Kamp
3f12caa180 Now that the sectorsize and mediasize are properties of the provider,
don't take the detour over the I/O path to discover them using getattr(),
we can just pick them out directly.

Do note though, that for now they are only valid after the first open
of the underlying disk device due compatibility with the old disk_create()
API.  This will change in the future so they will always be valid.

Sponsored by:   DARPA & NAI Labs.
2002-10-20 20:28:24 +00:00
Poul-Henning Kamp
943305f753 The g_id*() functions are not needed in the userland test-suite so
#ifdef _KERNEL them rather than deal with a copyin simulation.

Sponsored by:	DARPA & NAI Labs
2002-10-20 20:08:44 +00:00
Poul-Henning Kamp
48444d6262 Make the sectorsize a property of providers so we can include it in the XML
output.

Sponsored by:	DARPA & NAI Labs
2002-10-20 19:18:07 +00:00
Poul-Henning Kamp
14ac6812b9 Use %jd instead of %lld now that we have it. 2002-10-20 18:48:12 +00:00
Poul-Henning Kamp
9e2ebaa081 It makes more sense for the fwheads and fwsectors properties to be in
the provider stanza rather than the geom stanza.
2002-10-20 18:46:25 +00:00
Poul-Henning Kamp
8f9628a126 Include fwsectors and gfwheads in the XML output for the disks we know.
Sponsored by:	DARPA & NAI Labs.
2002-10-20 18:09:01 +00:00
Poul-Henning Kamp
87d4861cc5 Be consistent about functions being static.
Spotted by:	FlexeLint
2002-10-20 14:30:28 +00:00
Poul-Henning Kamp
8e91949016 Constify input to the arc4 seed function.
Implement the lockfile hunting in sector zero.

Sponsored by:	DARPA & NAI Labs.
2002-10-20 11:09:58 +00:00
Poul-Henning Kamp
0355b86e33 Don't track bio allocation in debug output.
Sponsored by:	DARPA & NAI Labs.
2002-10-20 08:45:17 +00:00
Poul-Henning Kamp
96b2c14b41 Style(9) and english(9) fixes.
Submitted by:	schweikh
2002-10-20 08:43:56 +00:00
Poul-Henning Kamp
9b232f1493 Make it possible to specify also via geom_t ID in the geom.ctl config ioctl.
Sponsored by:	DARPA & NAI Labs.
2002-10-20 08:42:18 +00:00
Poul-Henning Kamp
b6a185302e Fix a missing initialization. 2002-10-19 17:19:41 +00:00
Poul-Henning Kamp
19b5c7bc4b Add Geom Based Disk Encryption to the tree.
This is an encryption module designed for to secure denial of access
to the contents of "cold disks" with or without destruction activation.

Major features:

   * Based on AES, MD5 and ARC4 algorithms.
   * Four cryptographic barriers:
        1) Pass-phrase encrypts the master key.
        2) Pass-phrase + Lock data locates master key.
        3) 128 bit key derived from 2048 bit master key protects sector key.
        3) 128 bit random single-use sector keys protect data payload.
   * Up to four different changeable pass-phrases.
   * Blackening feature for provable destruction of master key material.
   * Isotropic disk contents offers no information about sector contents.
   * Configurable destination sector range allows steganographic deployment.

This commit adds the kernel part, separate commits will follow for the
userland utility and documentation.

This software was developed for the FreeBSD Project by Poul-Henning Kamp and
NAI Labs, the Security Research Division of Network Associates, Inc.  under
DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
research program.

Many thanks to Robert Watson, CBOSS Principal Investigator for making this
possible.

Sponsored by:   DARPA & NAI Labs.
2002-10-19 17:02:17 +00:00
Thomas Moestl
2408cfebf9 The argument to the DIOCGMEDIASIZE ioctl() is an off_t, not an u_int.
Reviewed by:	phk
2002-10-19 15:40:39 +00:00
Poul-Henning Kamp
37e7c03d19 Be consistent and return the NUL at the end of kern.geom.conf{xml,dot}.
Spotted by:	sam
2002-10-17 21:39:06 +00:00
Poul-Henning Kamp
aed99af2a3 NUL terminate sysctl kern.disks 2002-10-17 19:27:02 +00:00
Nate Lawson
02fcfac0ad Return an error if the drive reports heads/sectors that do not make sense.
This fixes a divide by zero in fdisk(8)

Reviewed by:	phk
2002-10-15 21:28:50 +00:00
Poul-Henning Kamp
220aecb807 Constification ? Yes, out that door, row on the left, one patch each.
Sponsored by:	DARPA & NAI Labs
2002-10-15 18:21:53 +00:00
Poul-Henning Kamp
b775674772 Remove a bogus local variable.
Sponsored by:	DARPA & NAI Labs.
2002-10-14 21:22:23 +00:00
Jake Burkholder
60e0e42e3c Moved geom class initialization to SI_SUB_DRIVERS from SI_SUB_PSEUDO.
This fixes mounting root from md(4) which calls disk_create() early.
2002-10-14 20:20:17 +00:00
Poul-Henning Kamp
6b4abfd6eb Implement the GEOMCONFIGGEOM ioctl which can be used to manually create
and configure an instance of a class on a give provider.

Sponsored by:	DARPA & NAI Labs
2002-10-14 10:05:23 +00:00
Poul-Henning Kamp
d0e17c1b91 Add more KASSERTS.
Sponsored by:	DARPA & NAI Labs.
2002-10-14 10:02:24 +00:00
Poul-Henning Kamp
3101ed1b7c Add the outline of the "/dev/geom.ctl" handling code.
Sponsored by:	DARPA & NAI Labs.
2002-10-13 20:33:33 +00:00
Poul-Henning Kamp
e970552d3a Give GEOM modules a chance to specify their own init routine, in case they
have special requirements.

Sponsored by:	DARPA & NAI Labs.
2002-10-13 18:42:35 +00:00
Poul-Henning Kamp
8523987b73 The CAM system has it's own ideas of what locks are to be held by whom.
So do GEOM.  Not a pretty sight.

Take all the interesting stuff out of GEOM::disk_create(), and leave just
the creation of the fake dev_t.  Schedule the topology munging to happen
in the g_event thread with g_call_me().

This makes disk_create() pretty lock-agnostic, almost lock-atheist.

Tripped over by:	peter
Sponsored by:	DARPA & NAI Labs
2002-10-11 20:52:44 +00:00
Poul-Henning Kamp
3f521b6022 Add support g_clone_bio() and g_std_done() to spawn multiple children
of a bio and correctly gather status when done.

Sponsored by:	DARPA & NAI Labs.
2002-10-09 07:11:59 +00:00
Poul-Henning Kamp
068088370c For now, don't wait for drives to stop returning EBUSY. There is too
much broken harware around it seems.

Sponsored by:	DARPA & NAI Labs.
2002-10-08 07:03:58 +00:00
Poul-Henning Kamp
b362694c3b Correctly deal with non-DEVBSIZE drives.
Allow BIO_DELETE through too.

This fixes swap-backed md(4) devices.

Sponsored by:   DARPA & NAI Labs.
2002-10-07 07:15:37 +00:00
Poul-Henning Kamp
430e557d3d Put a printf under #ifdef DIAGNOSTIC.
Sponsored by: DARPA & NAI Labs.
2002-10-07 06:57:00 +00:00
Poul-Henning Kamp
adfa3213c7 Copyin and copyout are only possible from a process-native thread,
and therefore we need a way for ioctl handlers to run in that thread
in GEOM.  Rather than invent a complicated registration system to
recognize which ioctl handler to use for a given ioctl, we still
schedule all ioctls down the tree as bio transactions but add a
special return code that means "call me directly" and have the
geom_dev layer do that.

Use this for all ioctls that make it as far as a diskdriver to
avoid any backwards compatibility problems.

Requested by:   scottl
Sponsored by:   DARPA & NAI Labs
2002-10-07 06:25:26 +00:00
Poul-Henning Kamp
1fc1a1ef2a This patch got lost in my trees: Pass setattr down to device drivers
as well.

Detected by:	scottl
Sponsored by:	DARPA & NAI Labs.
2002-10-05 21:55:31 +00:00
Poul-Henning Kamp
5f79a2e33a Fix argument order mistake when decoding disklabels from on-disk format.
Detected by:	jhay
Sponsored by:	DARPA & NAI Labs.
2002-10-05 18:52:06 +00:00
Poul-Henning Kamp
3bd6561289 NB: This commit does *NOT* make GEOM the default in FreeBSD
NB: But it will enable it in all kernels not having options "NO_GEOM"

Put the GEOM related options into the intended order.

Add "options NO_GEOM" to all kernel configs apart from NOTES.

In some order of controlled fashion, the NO_GEOM options will be
removed, architecture by architecture in the coming days.

There are currently three known issues which may force people to
need the NO_GEOM option:

boot0cfg/fdisk:
        Tries to update the MBR while it is being used to control
        slices.  GEOM does not allow this as a direct operation.

SCSI floppy drives:
        Appearantly the scsi-da driver return "EBUSY" if no media
        is inserted.  This is wrong, it should return ENXIO.

PC98:
        It is unclear if GEOM correctly recognizes all variants of
        PC98 disklabels.  (Help Wanted!  I have neither docs nor HW)

These issues are all being worked.

Sponsored by:	DARPA & NAI Labs.
2002-10-05 16:35:33 +00:00
Poul-Henning Kamp
2874f1cf36 Properly isolate the locking domains of sysctl from the topology lock
for the sysctls which report the configuration.

Sponsored by:	DARPA & NAI Labs.
2002-10-04 10:38:36 +00:00
Poul-Henning Kamp
0cc3011d52 Implement the "kern.disks" sysctl in GEOM.
This makes "mdconfig -l" work again.

Sponsored by:	DARPA & NAI Labs.
2002-10-04 10:15:26 +00:00
Poul-Henning Kamp
8be2bc5c6f Properly conditionalize a debugging printf.
Sponsored by:	DARPA & NAI Labs.
2002-10-04 10:06:19 +00:00
Poul-Henning Kamp
29c211954b Move GEOM's sysctls under kern.geom.
Sponsored by:	DARPA & NAI Labs.
2002-10-02 07:51:02 +00:00
Poul-Henning Kamp
a4319fd03d Put some failing ioctl related printfs under a suitable debug flag.
Sponsored by:	DARPA & NAI Labs.
2002-10-02 07:48:39 +00:00
Poul-Henning Kamp
0a2ece0481 Use the canonical root:operator 0640 for GEOM disk devices.
Spotted by:	brooks
Sponsored by:	DARPA & NAI Labs.
2002-10-01 19:33:09 +00:00
Poul-Henning Kamp
2fcf0b5c37 Don't restrict device drivers ability to sleep in the ioctl method, this
is actually entirely legal.

Do bio's with ioctls in them in a g_call_me() function.

Sponsored by:	DARPA & NAI Labs
2002-10-01 18:42:32 +00:00
Poul-Henning Kamp
e9a848359b Include <sys/diskmbr.h> instead of <sys/disklabel.h>
Sponsored by:	DARPA & NAI Labs.
2002-10-01 14:05:06 +00:00
Poul-Henning Kamp
3a24c28f37 Don the asbestos underwear and add the code which lets DIOCWDINFO
write modified disklabels back to disk.

Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:59:59 +00:00
Poul-Henning Kamp
72840432e0 Retire g_io_fail() and let g_io_deliver() take an error argument instead.
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:54:46 +00:00
Poul-Henning Kamp
90b1cd5615 Introduce g_write_data() function.
Sponsored by:	DARPA & NAI Labs
2002-09-30 08:50:47 +00:00
Poul-Henning Kamp
5b3317e9e6 Add missing g_enc_le2().
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:47:46 +00:00
Poul-Henning Kamp
5dcf28b202 Disable the g_sanity() check unless people ask for it in the debugflags.
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:46:29 +00:00
Poul-Henning Kamp
cd4f50fbb8 Make sure we don't loose our topology lock in a call_me() handler.
Sponsored by:	DARPA & NAI Labs.
2002-09-30 08:27:29 +00:00
Poul-Henning Kamp
079a527a3d Zero the local-variable mutexes before we call mtx_init() on them,
failing to do this may lead mtx_init() to belive they have already
been initialized.

Detected by:	Marc Recht <marc@informatik.uni-bremen.de>
2002-09-28 19:38:29 +00:00
Poul-Henning Kamp
4ae677009e Style, whitespace and lint fixes.
Sponsored by:	DARPA & NAI Labs.
2002-09-28 11:57:20 +00:00
Poul-Henning Kamp
eadf0ffdce Void functions cannot use return(foo) even if foo is also returning void.
Sponsored by:	DARPA & NAI Labs.
2002-09-28 11:43:20 +00:00
Poul-Henning Kamp
852f392456 First confirmed kill from my Flexelint license: Check return value
of g_clone_bio().

Detected by:	http://www.gimpel.com/html/flex.htm
Sponsored by:	DARPA & NAI Labs.
2002-09-28 08:16:50 +00:00