Commit Graph

56 Commits

Author SHA1 Message Date
Robert Wing
a2b559df1e geom_ctl.c: remove stale header files
- Remove "opt_geom.h", no kernel options are used.

- Remove <sys/sysctl.h>, no sysctl functionality is used here.

- Remove <sys/bio.h>, requirements for bio moved out in r112534.

- Remove <sys/lock.h> and <sys/mutex.h>, last used by DROP_GIANT() and
  PICKUP_GIANT(), which were removed in r115624.

- Remove <sys/disk.h> and <sys/kernel.h>, not used.

Reviewed by: phk, kevans (mentor)
Approved by: phk, kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D26805
2020-10-20 20:59:13 +00:00
Mateusz Guzik
d40bc60752 geom: clean up empty lines in .c and .h files 2020-09-01 22:14:09 +00:00
Xin LI
a450ecfdbd gctl_get_geom: Skip validation of g_class.
The caller from kernel is expected to provide an valid g_class
pointer, instead of traversing the global g_class list, just
use that pointer directly instead.

Reviewed by:		mav
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D25811
2020-07-26 22:30:55 +00:00
Xin LI
0ab851aac3 gctl_get_class, gctl_get_geom and gctl_get_provider: provide feedback
when the requested argument is missing.

Reviewed by:		cem
MFC after:		2 weeks
Differential revision:	https://reviews.freebsd.org/D25738
2020-07-22 02:14:27 +00:00
Warner Losh
283a5a3796 We don't even need Giant here. It isn't protecting anything internal
to geom, and nothing we call requires it to be held. It's left over
from a time when the latter wasn't the case. Retire it.

Reviewed in concept: scottl@
2019-11-23 23:44:00 +00:00
Chuck Silvers
1e00bb458d Add a new gctl_get_paraml_opt() interface to extract optional parameters from
the request.  It is the same as gctl_get_paraml() except that the request
is not marked with an error if the parameter is not present.

Approved by:	imp (mentor)
Reviewed by:	cem
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21972
2019-10-16 21:49:39 +00:00
Mark Johnston
cd2e908669 Define a constant for the maximum number of GEOM_CTL arguments.
Reviewed by:	eugen
MFC with:	r344305
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19271
2019-02-20 17:07:08 +00:00
Mark Johnston
60a92c781d Impose a limit on the number of GEOM_CTL arguments.
Otherwise a privileged user can trigger a memory allocation of
unbounded size, or an integer overflow in the subsequent
geom_alloc_copyin() call, leading to out-of-bounds accesses.

Hard-code a large limit to circumvent this problem.

admbug:		854
Reported by:	Anonymous of the Shellphish Grill Team
Reviewed by:	ae
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19251
2019-02-19 21:22:22 +00:00
Pedro F. Giffuni
3728855a0f sys/geom: 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.
2017-11-27 15:17:37 +00:00
Pedro F. Giffuni
b99bce73e2 geom: unsign some types to match their definitions and avoid overflows.
In struct:gctl_req, nargs is unsigned.

In mirror:
g_mirror_syncreqs is unsigned.

In raid:
in struct:g_raid_volume, v_disks_count is unsigned.

In virstor:
in struct:g_virstor_softc, n_components is unsigned.

MFC after:	2 weeks
2016-04-27 15:10:40 +00:00
Andrey V. Elsukov
524d7a4d4e Always free sbuf in gctl_free().
MFC after:	1 week
2014-01-23 21:30:31 +00:00
Andrey V. Elsukov
d14a7ff1f5 Remove another unneeded NULL check from geom_alloc_copyin().
Do copyout in case of gctl version mismatch and fix sbuf leak in
g_ctl_ioctl_ctl().

MFC after:	1 week
2014-01-23 20:25:38 +00:00
Andrey V. Elsukov
7f0e13dfe0 In gctl_copyin() remove unused error variable.
geom_alloc_copyin() can't return ENOMEM, so describe its fail as bad
control request. Add check for NULL pointer in gctl_dump(), since it
can be NULL when geom_alloc_copyin() failed.

MFC after:	1 week
2014-01-23 19:55:02 +00:00
Andrey V. Elsukov
625ee733e3 Fix typo in r261084.
Add to the gctl_error() an ability to specify error description even
if numeric error code is already specified. Also by default set
error code to EINVAL.

PR:		185852
MFC after:	1 week
2014-01-23 19:31:17 +00:00
Andrey V. Elsukov
ee839ce84c malloc() with M_WAITOK doesn't return NULL.
MFC after:	1 week
2014-01-23 19:07:22 +00:00
Konstantin Belousov
23b70c1ae2 Finish r210923, 210926. Mark some devices as eternal.
MFC after:	2 weeks
2011-01-04 10:59:38 +00:00
Dag-Erling Smørgrav
2616144e43 Add sbuf_new_auto as a shortcut for the very common case of creating a
completely dynamic sbuf.

Obtained from:	Varnish
MFC after:	2 weeks
2008-08-09 11:14:05 +00:00
Xin LI
a92b7d4982 - Be more verbose when saying "foo" not found.
- In gctl_get_geom(), don't issue error when we were not
   provided with an parameter, like gctl_get_provider() did.

Reviewed by:	pjd
2007-03-30 16:32:08 +00:00
Marcel Moolenaar
41063f9380 Change gctl_set_param() to return an error instead of setting an
error on the request.  Add a wrapper, gctl_set_param_err(), that
sets the error on the request from the error returned by
gctl_set_param() and update current callers of gctl_set_param()
to call gctl_set_param_err() instead.
This makes gctl_set_param() much more usable in situations where
the caller knows better what to do with certain (apparent) error
conditions and setting an error on the request is not one of the
things that need to be done.
2006-04-07 16:19:48 +00:00
Marcel Moolenaar
40fcaded53 o Don't cause a panic when the control request lacks a verb.
o  Don't set the error twice when the named class does not exist.
   It causes ioctl(2) to return with error EEXIST.
2005-09-18 23:54:40 +00:00
Poul-Henning Kamp
52d71e1a85 remove stale comments 2005-08-16 20:03:29 +00:00
Pawel Jakub Dawidek
cdae843174 Fix a long-standing bug. Error string has to be copyied from the user
process context.

Approved by:	phk
MFC after:	3 days
2005-04-08 09:28:08 +00:00
Poul-Henning Kamp
e8cde1ac6f Discontinue zero-length g_ctl arguments as "just give him this pointer"
transfers.  The necessary context for calling copyin() isn't available
anyway and automatic code-validation chokes on this.
2005-01-17 07:14:24 +00:00
Poul-Henning Kamp
85986ce002 Don't call g_waitidle(), it happens automagically now. 2004-10-23 20:52:15 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Poul-Henning Kamp
dc08ffec87 Device megapatch 4/6:
Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
70cd771337 The present defaults for the open and close for device drivers which
provide no methods does not make any sense, and is not used by any
driver.

It is a pretty hard to come up with even a theoretical concept of
a device driver which would always fail open and close with ENODEV.

Change the defaults to be nullopen() and nullclose() which simply
does nothing.

Remove explicit initializations to these from the drivers which
already used them.
2003-09-27 12:01:01 +00:00
Poul-Henning Kamp
fd02a4233e Only dump 512 bytes of debugging.
Always wait for things to settle before returning.
2003-07-02 08:07:07 +00:00
David E. O'Brien
50b1faef38 Use __FBSDID().
Approved by:	phk
2003-06-11 06:49:16 +00:00
Poul-Henning Kamp
b61e8fed30 Make sure we return an error message if the geom parameter is not
located.
2003-06-07 15:31:44 +00:00
Poul-Henning Kamp
a1a9b44569 Add missing va_end() calls.
Noticed by:	tmm
2003-06-07 10:16:53 +00:00
Poul-Henning Kamp
d6c5e71627 Introduce g_provider_by_name() function, and use it. 2003-06-04 18:17:52 +00:00
Poul-Henning Kamp
786a6905ec Return an indicative error message. 2003-06-02 20:35:37 +00:00
Poul-Henning Kamp
83d771de78 Simplify the GEOM OAM api: Drop the request type, and let everything
hinge on the "verb" parameter which the class gets to interpret as
it sees fit.

Move the entire request into the kernel and move changed parameters
back when done.
2003-06-01 13:47:51 +00:00
Poul-Henning Kamp
1ee055e692 Add gctl_set_param() function. 2003-05-04 19:24:34 +00:00
Poul-Henning Kamp
3e7b7bb1cb Plug memory leaks. 2003-05-02 12:49:41 +00:00
Poul-Henning Kamp
c4da4e46b2 Back out all the stuff that didn't belong in the last commit. 2003-05-02 06:42:59 +00:00
Poul-Henning Kamp
e65ab0f83f Use g_slice_spoiled() rather than g_std_spoiled().
Remember to free the buffer we got from g_read_data().
2003-05-02 06:36:14 +00:00
Poul-Henning Kamp
ca3d750e73 Introduce gctl_get_paraml() which gets a parameter only if it has the
right length.
2003-04-23 08:03:47 +00:00
Poul-Henning Kamp
fb9483af54 Make gctl_error() take printfline varargs. 2003-04-23 07:50:01 +00:00
Poul-Henning Kamp
ea9ab6bed2 Implement handling of CONFIG_GEOM OAM request. 2003-04-22 21:01:46 +00:00
Poul-Henning Kamp
70b4ddbb09 Collapse meta arguments into regular arguments, the distinction is
more trouble than it is worth.
2003-04-22 19:42:05 +00:00
Poul-Henning Kamp
68f156409e Make sure we don't ignore error codes. 2003-04-03 11:19:24 +00:00
Poul-Henning Kamp
4a1e273c48 Remove the old config interface, the new OAM is sufficiently functional
now.
2003-04-01 07:33:56 +00:00
Poul-Henning Kamp
afa2a5aab7 Remove some debugging in the new OAM[*] and add a debug flag for other
parts of it.

[*] I've been asked what "OAM" means:  It's an acronym used in the
telecom industry, "Operations And Maintenance", and there it covers
anything from a single unlabeled led on the frontpanel the the full
nightmare of CMIP for SS7.
2003-03-31 18:35:37 +00:00
Poul-Henning Kamp
63728c47e8 Run a revision on the OAM api.
Use prefix gctl_ systematically.
Add flag with access perms for each argument.
Add ro/rw versions of argument building functions.
General cleanup.
2003-03-27 14:35:00 +00:00
Poul-Henning Kamp
d49d7ca591 Turn /dev/geom.ctl from a GEOM class into a plain character device driver
instead, it will never see a disk-I/O transaction, so this is a lot simpler.
2003-03-24 13:37:15 +00:00
Poul-Henning Kamp
3117e54484 Marshalling stuff for OAM API. 2003-03-23 10:16:14 +00:00
Poul-Henning Kamp
b4b138c27f Including <sys/stdint.h> is (almost?) universally only to be able to use
%j in printfs, so put a newsted include in <sys/systm.h> where the printf
prototype lives and save everybody else the trouble.
2003-03-18 08:45:25 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00