Commit Graph

45 Commits

Author SHA1 Message Date
Jaakko Heinonen
e8f6ee4a99 Improve libgeom XML parsing error handling.
- Abort parsing and return an error if we run out of memory.
- Return EILSEQ from geom_xml2tree() for XML syntax errors.

Silence on:	freebsd-geom
2012-10-26 12:46:33 +00:00
Juli Mallett
019100de26 Back out r233646. Although it fixed most libgeom consumers under 32-bit
compatibility, it broke programs using devstat, under 32-bit compatibility and
not.

It's very difficult to fix the identifiers used by devstat, so this change is
simply being backed out.  Since changes to 3rd-party code seem likely, and may be
necessary to properly fix 32-bit binaries on 64-bit kernel, it would seem better
to make more invasive changes to fix GEOM's problems with 32-bit compatibility in
general.

The right thing to do is to replace all of the use of pointers as opaque
identifiers with a fixed-size (64-bit or even 32-bit should be enough for tracking
unique GEOM elments) field.  That probably maintains source compatibility with
most GEOM consumers, and allows xml2tree to make better assumptions about how to
decode the identifiers.

Submitted by:	Anton Yuzhaninov
2012-04-10 17:37:24 +00:00
Juli Mallett
3dce589cb9 Fix 32-bit libgeom consumers run on 64-bit kernels with COMPAT_FREEBSD32.
Kernel pointer values are used as opaque unique identifiers, which are then
used to reconstruct references between various providers, classes, etc., inside
libgeom from the source XML.  Unfortunately, they're converted to pointer-width
integers (in the form of pointers) to do this, and 32-bit userland pointers
cannot hold sensible representations (however opaque) of 64-bit kernel pointers
on all systems.

In the case where the leading bits are zero and 32 distinct bits of pointer can
be identified, this will happen to work.  On systems where the upper 32-bits of
kernel pointers are non-zero and the same for all kernel pointers, this will
result in double frees and all kinds of bizarre crashes and linkage between
objects inside libgeom.

To mitigate this problem, treat the opaque identifiers in the XML as C strings
instead, and internalize them to give unique and consistent per-object pointer
values in userland for each identifier in the XML.  This allows us to keep the
libgeom logic the same with only minor changes to initial setup and parsing.

It might be more sensible for speed reasons to treat the identifiers as numbers
of a large size (uintmax_t, say) rather than strings, but strings seem fine for
now.

(As an added side-effect, this makes it slightly easier to identify unresolved
 references, but nothing has been added to inform the user of those.)
2012-03-29 03:13:43 +00:00
Jaakko Heinonen
cdfaa45d48 Remove stale link.
PR:		151252
2010-12-04 08:44:56 +00:00
Pawel Jakub Dawidek
42e2e8990a Remove code duplication by introducing static gctl_param_add() function which
is now used by both gctl_ro_param() and gctl_rw_param().
2010-10-21 10:38:14 +00:00
Pawel Jakub Dawidek
91cca30d9c - Simplify gctl_get_handle() a bit.
- Prefer 'unsigned int' over 'u_int' in userland code.
2010-10-21 10:36:36 +00:00
Ed Maste
2cf6dafa3e Handle null return from XML_ParserCreate and fix a few memory leaks on
error conditions.

Submitted by:	Mark Johnston <mjohnston at sandvine dot com>
MFC after:	2 weeks
2010-10-05 15:27:44 +00:00
Joel Dahl
c2025a7660 Fix typos, spelling, formatting and mdoc mistakes found by Nobuyuki while
translating these manual pages.  Minor corrections by me.

Submitted by:	Nobuyuki Koganemaru <n-kogane@syd.odn.ne.jp>
2010-08-16 15:18:30 +00:00
Xin LI
1750e4f8d7 Correct a typo (when we talk about offset, it should
be offset, not size).

Submitted by:	pluknet at gmail com
2010-01-17 08:12:28 +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
Ed Schouten
e17aa6ff32 Add missing `void' keyword. 2009-12-31 01:37:26 +00:00
Edward Tomasz Napierala
a7c13ccc01 Add links to libgeom(3) where appropriate. 2009-05-19 12:10:48 +00:00
Ulf Lilleengen
31dff47f01 - Update the libgeom manpage with a description of g_device_path and
g_providername utility functions.

Approved by:	kib (mentor)
2008-09-08 06:27:00 +00:00
Ulf Lilleengen
f805f204b6 - Add a new ioctl for getting the provider name of a geom provider.
- Add a routine for looking up a device and checking if it is a valid geom
  provider given a partial or full path to its device node.

Reviewed by:	phk
Approved by:	pjd (mentor)
2008-09-07 13:54:57 +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
Ulf Lilleengen
7b6942a110 - Simplify the procedure of retrieving XML-data from the kernel.
- Fix a number of potential memory leaks in libgeom related to doing realloc
  without freeing old pointer if things go wrong.
- Fix a number of places in libgeom where malloc and calloc return values
  were not checked.
- Check malloc return value and provide sufficient warning messages when XML
  parsing fails.

PR:		kern/83464
Submitted by:	Dan Lukes <dan - at - obluda.cz>
Approved by:	kib (mentor)
2008-07-08 17:34:50 +00:00
Andrew Thompson
cbb0775d1a Fix spelling.
PR:		docs/124561
Submitted by:	Sam Banks
2008-06-13 21:49:21 +00:00
Pawel Jakub Dawidek
9ac6b8ae23 Use 'dowrite' as an argument name instead of too general 'write'. 2008-05-20 11:45:05 +00:00
Dag-Erling Smørgrav
5f145b19fc Remove parameter names from prototypes to avoid namespace issues. 2007-05-06 10:00:27 +00:00
Pawel Jakub Dawidek
fbda685d38 Implement and document some utility functions that can be used to communicate
with GEOM providers.

OK'ed by:	phk
2007-05-06 01:17:46 +00:00
Wojciech A. Koszek
0eedd05b19 Second call of sysctl() is used to gather a proper size of a memory chunk
needed to hold the GEOM tree. At this point, pointer 'p' has an improper
value (as it was used previously), and we're getting EFAULT. Fix this
functionality by passing NULL instead of 'p'.

This fixes mdconfig(8) -l output with high number of md(4) devices.

   Found by:	kris
Reviewed by:	phk
2007-05-01 10:47:09 +00:00
Ruslan Ermilov
70b0774919 Fix prototype. 2005-11-24 10:43:35 +00:00
Poul-Henning Kamp
90d93f7141 Check for NULL pointer return.
Spotted by:	marcus
2005-05-24 10:10:38 +00:00
Ruslan Ermilov
862b46f607 Markup, grammar, punctuation. 2004-07-01 18:20:57 +00:00
John Baldwin
ccac9da43b Make libgeom usable by C++ programs:
- Add DECL wrappers to libgeom.h.
- Rename structure members in libgeom.h to use a lg_ prefix for member
  names.  This is required because a few structures had members named
  'class' which made g++ very unhappy.
- Catch gstat(8) and gconcat(8) up to these API changes.

Reviewed by:	phk
2004-03-09 21:14:18 +00:00
Poul-Henning Kamp
4aa50d28b9 String the consumers into the list of the provider they are attached to.
Noticed by:	jhb
2004-03-08 16:37:08 +00:00
Poul-Henning Kamp
5e5bfe7757 Add manpages for the gctl API.
Submitted by:	le
Tweaks by:	phk
2004-03-07 16:07:57 +00:00
David E. O'Brien
4f4a104ee8 style.Makefile(5) 2003-08-18 15:25:39 +00:00
Gordon Tetlow
41d8423f71 Stage 3 of dynamic root support. Make all the libraries needed to run
binaries in /bin and /sbin installed in /lib. Only the versioned files
reside in /lib, the .so symlink continues to live /usr/lib so the
toolchain doesn't need to be modified.
2003-08-17 08:28:46 +00:00
Mark Murray
d368bc9f59 Remove GCC-specific debugging option.
OK'ed by:	phk
2003-07-24 19:53:02 +00:00
Philippe Charnier
b160a51e51 The .Fn function 2003-06-18 19:43:17 +00:00
Poul-Henning Kamp
7e02e189ae Add the part of the last commit which cvs appearantly didn't like
the first time.
2003-06-01 15:05:22 +00:00
Ruslan Ermilov
0b00d54eed Moved libgeom.so dependencies to where they belong.
Reviewed by:	phk
Approved by:	re (scottl)
2003-05-17 19:05:17 +00:00
Poul-Henning Kamp
64a5766ef7 Collapse the meta arguments into normal arguments, trying to distinguish
just makes our own life harder.
2003-04-22 19:31:00 +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
4b8938c1d5 Add marshalling functions for OAM api. 2003-03-23 10:15:02 +00:00
Poul-Henning Kamp
2892a228ad Use devstat instead of GEOM private statistics structure. 2003-03-18 09:53:46 +00:00
Poul-Henning Kamp
2ad2651a98 Constify arg to geom_lookupid().
Improve a diagnostic printf.
2003-03-17 08:22:48 +00:00
Ruslan Ermilov
ace5be682d mdoc(7) police: Scheduled sweep. 2003-02-24 22:53:26 +00:00
Alexey Zelkin
98e07ca0de Add appropriate MLINKS for functions documented in libgeom.3 2003-02-13 18:27:05 +00:00
Alexey Zelkin
3fe5cc64ff Fix some mdoc issues: add .Nd to NAME section, use valid .Lb argument,
use .Fn there appropriate
2003-02-13 18:25:48 +00:00
Poul-Henning Kamp
7bd4e7b4a0 Leak more stuff into libgeom. 2003-02-10 00:11:43 +00:00
Poul-Henning Kamp
5ddbc7e1f7 Lower WARNS to 3 until I track down a way to explain that I know what
I'm doing to sparc64's gcc
2003-02-08 16:08:17 +00:00
Poul-Henning Kamp
ba798fb226 Include <sys/time.h>, it's not the users problem that we use bintime
internally.
2003-02-08 15:49:26 +00:00
Poul-Henning Kamp
e13db58757 Add libgeom to the system.
Initially this only contains the functions for accessing the I/O
statistics data.
2003-02-08 15:15:56 +00:00