History log of /freebsd-11-stable/sbin/mdconfig/mdconfig.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 330449 05-Mar-2018 eadler

MFC r326276:

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

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.

No functional change intended.


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 289113 10-Oct-2015 trasz

Add 'p' postfix to mdconfig(8).

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 258909 04-Dec-2013 trasz

Add "null" backend to mdconfig(8). This does exactly what the name
suggests, and is somewhat useful for benchmarking.

MFC after: 1 month
No objections from: kib
Sponsored by: The FreeBSD Foundation


# 257036 23-Oct-2013 hrs

Return 0 if:

1. "-u N" specified, no -f, and mdN found,
2. no -u, "-f /pathname" specified, and mdN associated with /pathname found,
3. "-u N" specified, "-f /pathname" specified, and both of them found,
4. "-l" specified and no -f,
5. "-l" specified, "-f /pathname" specified, and /pathname found.

otherwise return -1.

Spotted by: Julian H. Stacey


# 253833 31-Jul-2013 delphij

Resolve fflag with realpath().

MFC after: 2 weeks


# 252523 02-Jul-2013 delphij

When listing with -f, skip all memory disks that are not vnode-backed.

Noticed by: kevlo
MFC after: 3 days


# 252051 20-Jun-2013 hrs

- Use length of _PATH_DEV instead of a hardcoded value[*].
- Use MD_NAME for "md".

Pointed out by: trasz [*]
MFC after: 1 week


# 252036 20-Jun-2013 hrs

eturn -1 when the specified backing store file is not found in the md
device list.

MFC after: 1 week


# 252033 20-Jun-2013 hrs

- Add "-f file" support to listing mode (-l). When a -f option is
specified, only md(4) devices which have the specified file as backing
store are displayed.
- Use MD_NAME instead of "md".
- Use _PATH_DEV instead of "/dev/".

MFC after: 1 week


# 243372 21-Nov-2012 jh

Disallow attaching preloaded memory disks via ioctl.

- The feature is dangerous because the kernel code didn't check
validity of the memory address provided from user space.
- It seems that mdconfig(8) never really supported attaching preloaded
memory disks.
- Preloaded memory disks are automatically attached during md(4)
initialization. Thus there shouldn't be much use for the feature.

PR: kern/169683
Discussed on: freebsd-hackers


# 238215 07-Jul-2012 trasz

Make it possible to resize md(4) devices.

Reviewed by: kib
Sponsored by: FreeBSD Foundation


# 232964 14-Mar-2012 trasz

Add missing "static".


# 230612 27-Jan-2012 trasz

Rewrite option parsing in mdconfig(8). This makes it more user-friendly
by removing the ordering requirements and adding more descriptive error
messages; it also makes it more readable and maintainable.

Sponsored by: The FreeBSD Foundation


# 230423 21-Jan-2012 trasz

Replace the beerware license on mdconfig(8) with standard 2-clause BSD.

Approved by: phk@


# 221232 29-Apr-2011 des

Somewhere around the 473rd time I mistyped "mdconfig file" instead of
"mdconfig -f file", I decided that it would be easier to make mdconfig
DWIM than to teach my fingers to type the correct command line.

MFC after: 3 weeks


# 221144 27-Apr-2011 des

whitespace nit - sorry for the churn


# 221143 27-Apr-2011 des

whitespace nit


# 218677 14-Feb-2011 brucec

Add a check to make sure the provider name is "mdN" before printing the
unit number.

Suggested by: jh
MFC after: 3 days


# 218652 13-Feb-2011 brucec

Only print the unit number when invoked with the -n flag.

PR: bin/144300
Submitted by: arundel
MFC after: 3 days


# 215247 13-Nov-2010 joel

Use "cylinder" instead of "cyl" for consistency.

Reviewed by: phk


# 202784 22-Jan-2010 jh

Make mdconfig(8) WARNS=6 clean:

- Constify geom_config_get() name argument.
- Add void keyword for usage().
- Initialize mdunit to NULL.
- Don't call md_prthumanval() at all if length is NULL.

Approved by: trasz (mentor)


# 202573 18-Jan-2010 jh

Print sizes up to INT64_MAX in md_prthumanval().

PR: bin/125365
Approved by: trasz (mentor)
MFC after: 2 weeks


# 187027 10-Jan-2009 trasz

Add the possibility to specify "-o force" with "mdconfig -du".

Reviewed by: scottl
Approved by: rwatson (mentor)
Sponsored by: FreeBSD Foundation


# 179910 21-Jun-2008 marck

Add -v (verbose) option to -l command, to show size and backing store
of all md devices at one time.

Approved by: phk
MFC after: 2 weeks


# 173676 16-Nov-2007 flz

Fix exit code when using -l on a non-existent md(4) device.

PR: conf/116177
Submitted by: Remi Guyomarch <rguyom@pobox.com>
MFC after: 3 days


# 166854 20-Feb-2007 n_hibma

Kris suggested that swap is a better choice as a default than malloc.

MFC: 1 week


# 166853 20-Feb-2007 n_hibma

[Found the original diff I made, see previous commit for other part]
Assume '-a' and '-t malloc' flags for '-s <size>' (malloc ramdisk) if not
specified.

Reviewed by: phk (some time ago)
MFC: 1 week


# 166852 20-Feb-2007 n_hibma

Make attach the default for -f. That way

mdconfig -f image

works like a charm.

Reviewed by: phk (some time ago)
MFC: 1 week


# 157173 27-Mar-2006 jasone

Unbreak the build.


# 157166 26-Mar-2006 wkoszek

For now, bring back some of the old bits as a fix for specifying md(4)
device number at creation time with -u option. Together with XMLizing
mdconfig(8), I broke this functionality.

This change is temporary. Complete fix will be commited soon.

Approved by: cognet (mentor)


# 157160 26-Mar-2006 wkoszek

Teach md(4) and mdconfig(8) how to understand XML. Right now there won't be
a problem with listing large number of md(4) devices. Either 'list' or
'query' mode uses XML.

Additionally, new functionality was introduced. It's possible to pass
multiple devices to -u:

# ./mdconfig -l -u md0,md1

Approved by: cognet (mentor)


# 157159 26-Mar-2006 wkoszek

Keep proper order of includes. Additionally, sort them. Make functions used
in that file static.

Approved by: cognet (mentor)


# 155807 18-Feb-2006 pjd

Use kld(3) for loading geom_md.ko.


# 153636 22-Dec-2005 dd

Sort the list results by the unit number. The list returned by the
kernel is in the order the devices were made, which is not useful to
the user. Also, remove the "%d more" test since the kernel does not
return the complete count in md_pad[0] (maybe it should?).

Submitted by: Wojciech A. Koszek


# 152309 11-Nov-2005 pjd

Rename GEOM class kernel module g_md.ko to geom_md.ko for consistency
with the rest.

mdconfig.c: Simplify mdmaybeload() function.
mdioctl.h: Removed (now unused) #define.
loader.conf: Sort GEOM classes properly.

OK'ed by: phk


# 149638 30-Aug-2005 csjp

When using files as backing stores for devices, and the user has requested the
device be created read+write, check to see if the backing store is read only
through the use of the access(2) system call. If this check fails returning
EACCES, EPERM or EROFS then gracefully downgrade the access to read only. Also
print a warning message to stderr, informing the user that the access mode
they requested is not available.

This behavior used to be handled by md(4) but was changed in revision 1.154

Discussed with: pjd, phk, Dario Freni <saturnero at freesbie dot org>
Reviewed by: phk


# 142926 01-Mar-2005 pjd

We can specify device size in bytes. Document this in usage.


# 142167 21-Feb-2005 mr

Document the terabyte "-s" parameter in the usage string.
Split the usage line to not exceed 80 chars.


# 141611 10-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


# 140627 22-Jan-2005 pjd

Allow to specify device size in bytes.

MFC after: 1 week


# 139359 27-Dec-2004 pjd

Rewrite piece of code which I committed some time ago that allows to
show file name for 'mdconfig -l -u <x>' command.
This allows to preserve API/ABI compatibility with version 0 (that's why
I changed version number back to 0) and will allow to merge this change
to RELENG_5.

MFC after: 5 days


# 137669 13-Nov-2004 ru

Sync usage() with manpage SYNOPSIS and code.


# 137310 06-Nov-2004 pjd

For file backed md(4) devices output their source file via
'mdconfig -l -u <unit>'.
Bump version number, as this change breaks ABI/API.


# 137300 06-Nov-2004 dd

If there aren't any devices to list, output nothing instead of an
empty line. This is consistent with other utilities.

While I'm here, remove artifacts of the previous list implementation.


# 135340 16-Sep-2004 pjd

- Make md(4) 64-bit clean.
After this change it should be possible to use very big md(4) devices.
- Clean up and simplify the code a bit.
- Use humanize_number(3) to print size of md(4) devices.
- Add 't' suffix which stands for terabyte.
- Make '-S' to really work with all types of devices.
- Other minor changes.


# 134965 08-Sep-2004 jmg

add support for documented readonly option...
also print out the option that is unknow so that the user knows what (s)he
did wrong..

MFC after: 3 days


# 133357 09-Aug-2004 jmg

change the name of the md module, to g_md, introduce a define with the
name MD_MODNAME, and make mdconfig use this new define...


# 132629 25-Jul-2004 phk

Give better diagnostic for problems with backing files.


# 126821 10-Mar-2004 phk

Fix a long-standing deadlock issue with vnode backed md(4) devices:

On vnode backed md(4) devices over a certain, currently undetermined
size relative to the buffer cache our "lemming-syncer" can provoke
a buffer starvation which puts the md thread to sleep on wdrain.

This generally tends to grind the entire system to a stop because the
event that is supposed to wake up the thread will not happen until a fair
bit of the piled up I/O requests in the system finish, and since a lot
of those are on a md(4) vnode backed device which is currently waiting
on wdrain until a fair amount of the piled up ... you get the picture.

The cure is to issue all VOP_WRITES on the vnode backing the device
with IO_SYNC.

In addition to more closely emulating a real disk device with a
non-lying write-cache, this makes the writes exempt from rate-limited
(there to avoid starving the buffer cache) and consequently prevents
the deadlock.

Unfortunately performance takes a hit.

Add "async" option to give people who know what they are doing the
old behaviour.


# 117430 11-Jul-2003 kan

Do not compare unsigned int values with ULONG_MAX. The comparison is
always false on 64bit platforms and GCC 3.3.1 issues warning there.


# 116194 11-Jun-2003 rwatson

Add "-n" argument, which causes mdconfig to simply print the unit
number X, rather than mdX, making it easier to script tests that
use md devices but don't want to make assumptions about any existing
md use (such as in diskless environments).


# 113289 09-Apr-2003 phk

Add a couple of undocumented test options to MD(4) to aid in regression
testting of GEOM.


# 112947 01-Apr-2003 yar

Give clearer diagnostics on some cases of invalid
combinations of mdconfig(8) command-line arguments.

Make mdconfig(8) accept "-a -f file -o options"
equally with "-a -f file" (assuming "-t vnode".)


# 111818 03-Mar-2003 phk

Add a "-S sectorsize" option to enable Kirk to find a bug :-)


# 109930 27-Jan-2003 phk

Don't use the kern.disks sysctl to find a list of md devices, use the
MDIOCLIST ioctl instead.

Spotted by: keramida


# 104773 10-Oct-2002 keramida

Make sure strsep() gets a nul-terminated string.

Reviewed by: phk


# 102224 21-Aug-2002 imp

Don't use NULL where you really mean 0 to sysctlbyname.


# 95258 22-Apr-2002 des

Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.


# 92874 21-Mar-2002 mike

Revert 1.20:
Memory disks may be used for other purposes besides newfs(8), so it
isn't helpful to require the minimum size meet newfs(8)'s criteria.


# 92866 21-Mar-2002 mike

Provide a proper error message in mdconfig(8) when a filesystem is too
small, instead of a less meaningful error in newfs(8).


# 88249 20-Dec-2001 dd

Actually make use of the md_version field of 'struct mdio'. In order
not to needlessly break compatibility, decrement MDIOVERSION to 0.

Approved by: phk


# 81258 07-Aug-2001 dd

Move all the prototypes to one place.


# 81257 07-Aug-2001 dd

Introduce a force option, MD_FORCE, that instructs the driver to
bypass some extra anti-foot-shooting measures. Currently, its only
effect is to allow detaching a device while it's still open (e.g.,
mounted). This is useful for testing how the system reacts to a disk
suddenly going away, which can happen with some removeable media.

At this point, the force option is only checked on detach, so it
would've been possible to allow the option to be passed with the
MDIOCDETACH operation. This was not done to allow the possibility of
having the force flag influence other tests in the future, which may
not necessarily deal with detaching the device.

Reviewed by: sobomax
Approved by: phk


# 79863 18-Jul-2001 dd

Use MD_NAME and MDCTL_NAME constants where appropriate.


# 78526 21-Jun-2001 dd

Constify mdmaybeload(), add a prototype for usage(), and get rid of a
sizeof(int) == sizeof(long) assumption; clamp down with WARNS=2.


# 78525 20-Jun-2001 dd

Don't assume the length of MD_NAME is 2.


# 78524 20-Jun-2001 dd

Fail if -s isn't specified for an MD_MALLOC or MD_SWAP disk; the
driver itself obviously won't configure such a disk, but the error
returned (EDOM) is more cryptic to the average user than it should be.

Also assert that the argument to -u is in fact a valid unit; don't
just accept any string to mean 0.

Approved by: phk


# 74052 09-Mar-2001 sobomax

In the absence of explicit ``-t type'' option assume that ``-f file''
implies ``-t vnode''.

Approved by: phk


# 74044 09-Mar-2001 phk

1) If mdconfig isn't given an action argument, it assumes detach.
2) Running `mdconfig -l` without any attached devices results in
mdconfig printing "md0" to standard output.

Submitted by: dd [1]

[1] no, not "dd(1)" but "Dima Dorfman"


# 73094 26-Feb-2001 phk

Remove "autounit" from settable options, it's the default unless you
specify -u.

Spotted by: dcs


# 73027 25-Feb-2001 phk

Forgot to remove unneeded "intcmp" function.


# 73026 25-Feb-2001 phk

Make "md" and "mdctl" macroized parameters.

Implement "-l" option to mdconfig which can list one or all md devices.

Submitted by: Dima Dorfman <dima@unixfreak.org>


# 72981 24-Feb-2001 phk

Make md/mdconfig do kld.

Submitted by: dcs


# 71865 31-Jan-2001 phk

Strip optional prefixes "/dev/" and "md" from the -u argument.


# 71745 28-Jan-2001 phk

Duh, the version of mdconfig.c I committed came from the wrong machine.

Commit the right version, but without the -b option which is too evil
for the present.

Remove -b and preload from the manpage as well.


# 70573 01-Jan-2001 phk

Add padding space and a version number to the md_ioctl structre for future
extension.

Add ability to create a preload disk giving an address and a length
(suggested by imp)

Fix bug relating to very small md(4) devices.

Update md.c copyright to reflect the status of code copied from vn.c.
(noticed by dillon)


# 70541 31-Dec-2000 phk

This is the first snapshot of the new all-singing-and-dancing md(4).

Using the mdconfig(8) program you can now configure memory disks
on malloc(9), swap or a file/vnode. preloaded md disks also work
as usual.


# 70538 31-Dec-2000 phk

Improve cmdline parsing and messages.

Add a rudimentary man-page. (I'm no mdoc wizard, feel free to attack my
mistakes and blunders)


# 70448 28-Dec-2000 phk

Preliminary scaffolding for the new integrated vn+md device driver.

I decided to work on the md(4) driver and integrate the vn(4)
functionality into it mainly based on the name being more suitable.
Ideally 'vd' as in "virtual disk" would probably be the most logical
but our sound-master pointed out that this would cause uncontrollable
fits of giggles in the brits. Another complication would the needed
changes to the ramdisk boot/root functionality.

The vn driver will stay around for some time after I complete this
merge for transition reasons, and I'll make it whine to people that
they should migrate to the md(4) driver for some time before it
dies.

The kernel part of the new md(4) driver will be committed after more
testing.