Commit Graph

12 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
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
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
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
Poul-Henning Kamp
90d93f7141 Check for NULL pointer return.
Spotted by:	marcus
2005-05-24 10:10:38 +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
2ad2651a98 Constify arg to geom_lookupid().
Improve a diagnostic printf.
2003-03-17 08:22:48 +00:00
Poul-Henning Kamp
7bd4e7b4a0 Leak more stuff into libgeom. 2003-02-10 00:11:43 +00:00