Page MenuHomeFreeBSD

libbe: Move libbe_handle definition to be.h
AbandonedPublic

Authored by otis on Sep 22 2024, 2:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 17 2024, 6:30 PM
Unknown Object (File)
Oct 17 2024, 8:27 AM
Unknown Object (File)
Oct 8 2024, 11:49 PM
Unknown Object (File)
Sep 26 2024, 2:00 AM
Subscribers
None

Details

Reviewers
imp
rcm
kevans
Summary

In order to make be.h (and libbe) self-contained, move
libbe_handle definition from be_impl.h to be.h

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 59558
Build 56445: arc lint + arc unit

Event Timeline

otis requested review of this revision.Sep 22 2024, 2:04 PM
otis created this revision.

Can you explain more on why you think you want this? The entire point was to hide the interface and avoid it becoming part of the ABI we need to care about.

Can you explain more on why you think you want this? The entire point was to hide the interface and avoid it becoming part of the ABI we need to care about.

To be able to compile anything using be.h (except from bectl).

FWIW, take this simple code:

otis@jb131:~/work/libbe % cat m.c
#include <be.h>

int main(int argc, char *argv[])
{
        libbe_handle_t *lbh;

        lbh = libbe_init(NULL);
        libbe_close(lbh);
        return 0;
}

and use:

cc -o x x.c -lbe

then the result is:

otis@jb131:~/work/libbe % cc -o m m.c -lbe
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:160:15: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  160 | _SYS_NVPAIR_H uint_t nvlist_nvflag(nvlist_t *);
      |               ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:184:11: error: unknown type name 'boolean_t'
  184 |     const boolean_t *, uint_t);
      |           ^
/usr/include/sys/nvpair.h:186:11: error: unknown type name 'uchar_t'
  186 |     const uchar_t *, uint_t);
      |           ^
/usr/include/sys/nvpair.h:218:5: error: unknown type name 'boolean_t'
  218 |     boolean_t *);
      |     ^
/usr/include/sys/nvpair.h:219:70: error: unknown type name 'uchar_t'
  219 | _SYS_NVPAIR_H int nvlist_lookup_byte(const nvlist_t *, const char *, uchar_t *);
      |                                                                      ^
/usr/include/sys/nvpair.h:239:5: error: unknown type name 'boolean_t'
  239 |     boolean_t **, uint_t *);
      |     ^
/usr/include/sys/nvpair.h:239:19: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  239 |     boolean_t **, uint_t *);
      |                   ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:240:70: error: unknown type name 'uchar_t'
  240 | _SYS_NVPAIR_H int nvlist_lookup_byte_array(nvlist_t *, const char *, uchar_t **,
      |                                                                      ^
/usr/include/sys/nvpair.h:241:5: error: unknown type name 'uint_t'; did you mean 'uint8_t'?                                                                         [55/1849]
  241 |     uint_t *);
      |     ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:243:5: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  243 |     uint_t *);
      |     ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:245:17: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  245 |     uint8_t **, uint_t *);
      |                 ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:247:17: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  247 |     int16_t **, uint_t *);
      |                 ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:249:18: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  249 |     uint16_t **, uint_t *);
      |                  ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:251:17: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  251 |     int32_t **, uint_t *);
      |                 ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:

and so forth.

The other thing may be that something is not well documented.

The above errors are from a pristine box (and I'm following man libbe. When I add CFLAGS et al similar yo what bectl has, then it gets better, but the libbe_handle_t is not visible, because its definition is in be_impl.h).

Questions, so many questions...

Can you explain more on why you think you want this? The entire point was to hide the interface and avoid it becoming part of the ABI we need to care about.

To be able to compile anything using be.h (except from bectl).

FWIW, take this simple code:

otis@jb131:~/work/libbe % cat m.c
#include <be.h>

int main(int argc, char *argv[])
{
        libbe_handle_t *lbh;

        lbh = libbe_init(NULL);
        libbe_close(lbh);
        return 0;
}

and use:

cc -o x x.c -lbe

then the result is:

otis@jb131:~/work/libbe % cc -o m m.c -lbe
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:160:15: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  160 | _SYS_NVPAIR_H uint_t nvlist_nvflag(nvlist_t *);
      |               ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:184:11: error: unknown type name 'boolean_t'
  184 |     const boolean_t *, uint_t);
      |           ^
/usr/include/sys/nvpair.h:186:11: error: unknown type name 'uchar_t'
  186 |     const uchar_t *, uint_t);
      |           ^
/usr/include/sys/nvpair.h:218:5: error: unknown type name 'boolean_t'
  218 |     boolean_t *);
      |     ^
/usr/include/sys/nvpair.h:219:70: error: unknown type name 'uchar_t'
  219 | _SYS_NVPAIR_H int nvlist_lookup_byte(const nvlist_t *, const char *, uchar_t *);
      |                                                                      ^
/usr/include/sys/nvpair.h:239:5: error: unknown type name 'boolean_t'
  239 |     boolean_t **, uint_t *);
      |     ^
/usr/include/sys/nvpair.h:239:19: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  239 |     boolean_t **, uint_t *);
      |                   ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:240:70: error: unknown type name 'uchar_t'
  240 | _SYS_NVPAIR_H int nvlist_lookup_byte_array(nvlist_t *, const char *, uchar_t **,
      |                                                                      ^
/usr/include/sys/nvpair.h:241:5: error: unknown type name 'uint_t'; did you mean 'uint8_t'?                                                                         [55/1849]
  241 |     uint_t *);
      |     ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:243:5: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  243 |     uint_t *);
      |     ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:245:17: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  245 |     uint8_t **, uint_t *);
      |                 ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:247:17: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  247 |     int16_t **, uint_t *);
      |                 ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:249:18: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  249 |     uint16_t **, uint_t *);
      |                  ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:
/usr/include/sys/nvpair.h:251:17: error: unknown type name 'uint_t'; did you mean 'uint8_t'?
  251 |     int32_t **, uint_t *);
      |                 ^
/usr/include/sys/_stdint.h:54:20: note: 'uint8_t' declared here
   54 | typedef __uint8_t               uint8_t;
      |                                 ^
In file included from m.c:1:
In file included from /usr/include/be.h:31:
In file included from /usr/include/libnvpair.h:29:

and so forth.

The other thing may be that something is not well documented.

This one is standard ZFS/SPL shittery, and not much we can do about that at libbe.

The above errors are from a pristine box (and I'm following man libbe. When I add CFLAGS et al similar yo what bectl has, then it gets better, but the libbe_handle_t is not visible, because its definition is in be_impl.h).

What are you doing that requires libbe_handle_t to be visible? Your sample code should be fine, none of that requires knowledge of the layout/size of the handle because you're just operating on pointers. There's something else going on there.

(edit: "visible" -> "not opaque" -- it's visible, the definition is there as a typedef)