Commit Graph

55 Commits

Author SHA1 Message Date
Ed Schouten
bf70becee6 More -Wmissing-variable-declarations fixes.
In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.
2012-10-19 14:49:42 +00:00
Alexander Motin
83d165c127 MFgraid/head r217014:
Make `geom XXX list` and `geom XXX status` outputs more consistent:
Add -a options to print all geoms, not only ones with providers.
Add -g option for `status` to report geom's names, not provider's.
Make `status` by default report provider's status (if present), not geom's.
Make `status` report consumer's statuses, not only "synchronized" field.
2011-03-24 19:11:05 +00:00
David E. O'Brien
8494b7389a Rename the generic "CLASS" to the more specific "GEOM_CLASS".
While I'm here remove redundancy and inconsistencies.

Obtained from: Juniper Networks
2010-12-15 23:45:12 +00:00
Pawel Jakub Dawidek
628ec6d344 Remove dead code. 2010-09-14 20:54:22 +00:00
Pawel Jakub Dawidek
fa5383a260 Remove now unused G_TYPE_ASCNUM. 2010-09-14 16:22:22 +00:00
Pawel Jakub Dawidek
f104beb787 Remove dot which shouldn't be here, as err(3) will attach error message
at the end of the string.
2010-09-14 11:19:21 +00:00
Pawel Jakub Dawidek
7648b1e9c0 Introduce special G_VAL_OPTIONAL define, which when given in value field
tells geom(8) to ignore it when it is not given and don't try to obtain
default value.
2010-09-14 11:13:46 +00:00
Pawel Jakub Dawidek
315fcbf7db Add G_TYPE_MULTI flag, which when set for the given option, will
allow the option to be specified multiple times. This will help to
implement things like passing multiple keyfiles to geli(8) instead of
cat(1)ing them all into stdin and reading from there using one '-k -'
option.
2010-09-13 13:59:28 +00:00
Pawel Jakub Dawidek
946e2f3595 - Remove gc_argname field. It was introduced for gpart(8), but if I
understand everything correctly, we don't really need it.
- Provide default numeric value as strings. This allows to simplify
  a lot of code.
- Bump version number.
2010-09-13 13:48:18 +00:00
Pawel Jakub Dawidek
a478ea7490 - Allow to specify value as const pointers.
- Make optional string values always an empty string.
2010-09-13 08:56:07 +00:00
Dag-Erling Smørgrav
35efcc8b69 expand_number(3) takes a uint64_t * now; intmax_t was never correct
except by accident.

MFC after:	3 weeks
2010-08-19 11:20:24 +00:00
Andrey V. Elsukov
79d89bb0ab Remove G_TYPE_ASCLBA type and replace it with G_TYPE_STRING in gpart.
Move code that converts params from humanized numbers to sectors count
to subr.c and adjust comment.
Add post-processing for "size" and "start offset" params in gpart,
now they are properly converted to sectors count with known sector size
that can be greater that 512 bytes.
Also replace "unsigned long long" type to "off_t" for unify code since
it used for medium size in libgeom(3) and DIOCGMEDIASIZE ioctl.

PR:		bin/146277
Reviewed by:	marcel (previous version)
Approved by:	kib (mentor)
MFC after:	1 month
2010-06-21 08:24:50 +00:00
Xin LI
00b236aac2 Also output stripeoffset for consumer even if stripesize is zero, while
stripeoffset is non-zero.

Pointed out by:	mav
2010-01-18 19:39:55 +00:00
Xin LI
e192c6e8e8 Stripe offset may be usable even without stripe size known,
so give the output when either is non-zero.

Suggested by:	mav
2010-01-17 08:10:37 +00:00
Xin LI
35daa28f30 Expose stripe offset and stripe size through libgeom and geom(8) userland
utilities.

Reviewed by:	pjd, mav (earlier version)
2010-01-17 06:20:30 +00:00
Pawel Jakub Dawidek
87070efb4d Update copyright years. 2009-09-06 06:49:59 +00:00
Pawel Jakub Dawidek
963feac4e9 For any given subcommand allow to specify multi-line usage (separated by \n).
Submitted by:	Mel Flynn
2009-09-06 06:48:50 +00:00
Marcel Moolenaar
dc344ca5a4 Allow humanized numbers for LBAs, as well as partition indices for
gpart(8). LBAs in particular are ugly. The ganularity is a sector,
but users expect byte granularity when specifying the size or offset
with a SI unit. Handle LBAs specially to deal with this.
2009-06-07 20:12:14 +00:00
Ulf Lilleengen
5d82438617 - Use a separate pointer to the allocated memory for freeing, as strsep may
modify the pointer argument passed to it. This triggered an assert in malloc
  when a geom command being run under the livefs environment.

PR:		bin/130632
Submitted by:	Dimitry Andric <dimitry -at- andric.com>
Pointy hat to:	me
MFC after:	2 days
2009-02-02 19:22:53 +00:00
Marcel Moolenaar
14bf405be4 Replace checks for RESCUE in sources with checks for STATIC_GEOM_CLASSES
and define STATIC_GEOM_CLASSES when building the rescue binary. This way
geom can more easily be part of other crunched binaries, as it requires
only a Makefile change.
2008-06-04 20:07:59 +00:00
Xin LI
bc69d66f2f Make it possible to build glabel into rescue geom(8) utility.
Ok'ed by:	marcel
No objection:	-current@
2008-03-05 23:31:49 +00:00
Ulf Lilleengen
2591e96ce2 - Make geom commands handle multiple library paths in the GEOM_LIBRARY_PATH
environment variable using ':' as a separator.

Approved by:	pjd (mentor)
MFC after:	3 days
2008-02-04 12:17:02 +00:00
Marcel Moolenaar
a16f9b367d Allow building of a special rescue version of geom that
has a subset of the classes compiled-in.
2007-11-04 00:32:54 +00:00
Pawel Jakub Dawidek
e84091cb52 For arguments declared as numbers always use expand_number(3).
This allows to use numbers in human-readable form in many geom(8)
utilities. Such a simple change and makes live so much nicer.
Some examples:

	gstripe label -s 16k
	gmirror label -s 4k
	gnop create -o 1g -s 128m -S 2k
	gjournal label -s 2g
	geli label -i 128k -s 4k

Approved by:	re (kensmith)
2007-09-21 10:00:05 +00:00
Pawel Jakub Dawidek
764907187e Use 'val' function argument instead of 'optarg' global variable.
This doesn't fix any real bug, because in those tw ocases we always
passed 'optarg' as 'val'.

Approved by:	re (kensmith)
2007-09-21 09:52:43 +00:00
Marcel Moolenaar
cf805fab87 Fix the construction of the gctl_req that got broken by my
previous commit and that introduced optional parameters.
Existing classes (like geli(8)) use empty strings by default
and expect the parameter to be passed to the kernel as such.
Also, the default value of a string argument can be NULL.
Fix both cases by making the optional parameter conditional
upon gc_argname being set and making sure to test for NULL
before dereferencing the pointer.

Reported by: brueffer@
2007-05-17 15:34:51 +00:00
Marcel Moolenaar
3cf55d3ab9 Add gpart(8).
In order to support gpart(8), geom(8) needs to support a named
argument. Also, optional string parameters are a requirement.
Both have been added to the infrastructure. The former required
all existing classes to be adjusted.
2007-05-15 20:25:18 +00:00
Pawel Jakub Dawidek
5d47cd0f1a Exit status should be 1 on error.
PR:		bin/110705
Reported by:	Tom Judge
MFC after:	2 weeks
2007-03-23 21:05:36 +00:00
Pawel Jakub Dawidek
6fc6000883 MFp4:
- Print proper error message when argument is specified twice.
  Before the change it was detected properly, because of how
  G_OPT_DONE() macro worked.
- Use err(3) functions where appropriate.
- Add some assertions.
- Bump version number, because G_TYPE_BOOL addition breaks API and ABI.

Changes:	98721,98722,98723,101360,106985
2006-09-30 14:39:18 +00:00
Pawel Jakub Dawidek
cb94ab3088 Allocate memory for NUL-termination as well.
MFC after:	2 days
2006-04-07 15:33:04 +00:00
Pawel Jakub Dawidek
66aa222e60 Remove trailing spaces. 2006-02-01 12:11:37 +00:00
Pawel Jakub Dawidek
f13942a746 - The geom(8) utility only uses three types of arguments: string (char *),
value (intmax_t) and boolean (int).
  Based on that provide three functions:
        - gctl_get_ascii()
        - gctl_get_int()
        - gctl_get_intmax()
- Hide gctl_get_param() function, as it is only used internally in
  subr.c.
- Allow to provide argument name as (fmt, ...).
- Assert geom(8) bugs (missing argument is a geom(8) bug).

- Clean-up and simplify the code by using new functions and assumtions
  (no more checking for missing argument).

Tested by:	regression tests
2005-12-07 01:38:27 +00:00
Pawel Jakub Dawidek
a73148d28d Unfortunately dlerror(3) returns string, so there is no clean way to
ignore "no such file" errors only, which I wanted to do.
Because of this I ignored all other errors on dlopen(3) failure as well,
which isn't good.
Fix this situation by calling access(2) on library file first and ignore
only ENOENT error. This allows to report all the rest of dlopen(3) errors.

MFC after:	3 days
2005-08-14 21:55:18 +00:00
Pawel Jakub Dawidek
760fde0677 Remove trailing spaces. 2005-04-29 07:57:50 +00:00
Pawel Jakub Dawidek
53767efdce Empty error buffer is not an error.
MFC after:	3 weeks
2005-04-07 06:46:11 +00:00
Pawel Jakub Dawidek
1bcfab7f56 Fix use of uninitialized buf[0].
Reported by:	stefanf
MFC after:	3 days
2005-03-22 22:05:44 +00:00
Pawel Jakub Dawidek
ee602fbb50 Be sure that class name storaed in 'class_name' is lower case.
MFC after:	1 week
2005-03-14 15:00:51 +00:00
Pawel Jakub Dawidek
c979e2069c - Add gc_usage field to g_command structure. This will allow to define
usage for a subcommand, so no 'usage' function has to be implemented
  in class library.
- Bump version number as it breaks ABI, but don't provide backward
  compatibility, because there are probably no external consumers of this
  geom(8).
This allows to print more precise usage for standard commands and simplify
class libraries a bit.

MFC after:	1 week
2005-03-14 14:24:46 +00:00
Pawel Jakub Dawidek
ba6821f0d0 Add '-s' option to 'status' subcommand. It produces script-friendly output:
# gmirror status
       Name    Status  Components
mirror/root  COMPLETE  ad0s1a
                       ad2s1a
mirror/data  DEGRADED  da0
                       da1 (76%)
                       da2
# gmirror status -s
       Name    Status  Components
mirror/root  COMPLETE  ad0s1a
mirror/root  COMPLETE  ad2s1a
mirror/data  DEGRADED  da0
mirror/data  DEGRADED  da1 (76%)
mirror/data  DEGRADED  da2

MFC after:	1 week
2005-03-14 12:33:19 +00:00
Pawel Jakub Dawidek
da80913d35 Use int instead of size_t (%*s needs int).
MFC after:	1 week
2005-03-14 08:34:02 +00:00
Xin LI
257eeb8e0b printf(3) expects that %*s having an int parameter, which generates
warning on 64-bit platforms.  Explicitly cast these values to int
to work around this issue, as these values are tend to be small.

Spotted by:	ia64 tinderbox
2005-03-14 04:33:13 +00:00
Pawel Jakub Dawidek
18ee884076 Add 'status' command which prints general information about devices.
For example:

# gmirror status
       Name    Status  Components
mirror/root  COMPLETE  ad0s1a
                       ad2s1a
mirror/data  DEGRADED  da0
                       da1 (76%)
                       da2

MFC after:	1 week
2005-03-13 19:34:27 +00:00
Pawel Jakub Dawidek
c88a220206 Update copyrights. 2005-03-13 19:11:57 +00:00
Pawel Jakub Dawidek
2d76e2db38 Change function names related to 'list' command from 'show_one_*' to
'list_one_*'.

MFC after:	1 week
2005-03-13 19:10:13 +00:00
Pawel Jakub Dawidek
5fd66a44d8 When listing all devices (geoms) from the given class, skip geoms without
providers.
This prevents from listing geoms like <name>.sync which can be confusing.
It still allows to show details about it by giving its name when listing.

MFC after:	1 week
2005-03-13 16:45:41 +00:00
Pawel Jakub Dawidek
3bad06e9ba - Add GEOM_LIBRARY_PATH environment variable which allows to specify an
alternative to /lib/geom/ path where shared libraries are stored.
- Improve debugging.

MFC after:	3 days
2005-02-27 21:14:58 +00:00
Pawel Jakub Dawidek
687b001501 Detect if class name is '-h' or 'help' and if it is, show general help
message, i.e.:
	geom: usage: geom <class> <command> [options]

PR:		bin/71537
Submitted by:	bugghy <bugghy@phenix.rootshell.be>
MFC after:	5 days
2004-12-28 17:07:18 +00:00
Pawel Jakub Dawidek
138cedfdc6 - Show all commands in usage, even if those commands are not available.
- When command is not available, just say it, instead of says, that command
  is unknown. Old behaviour seems to be too confusing.
2004-09-17 08:38:53 +00:00
Pawel Jakub Dawidek
f792f1d865 - If error string begins with "warning: ", don't exit, treat it as a warning
only.
- Use getprogname() function when informing about versions problem.
2004-08-28 02:29:40 +00:00
Pawel Jakub Dawidek
fe5e0baab7 Don't use version number in library name. The library version is checked
after dlopen() anyway, so we should be safe.

Suggested by:	ru
2004-08-02 09:05:29 +00:00