Skip to content

Commit 0d44b58

Browse files
authored
libshare: fold into libzfs and reorg headers a little
libzfs is the only user of libshare, and only internally, so there's no particular reason to build it separately, nor to export its symbols. So, pull it into libzfs proper, remove its "public" header, and hide its symbols. The bare minimum "public" API is just to count and enumerate the supported share types. These are moved to libzfs.h with the other share API. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #18072
1 parent 962e688 commit 0d44b58

File tree

20 files changed

+337
-449
lines changed

20 files changed

+337
-449
lines changed

cmd/zfs/zfs_main.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7339,15 +7339,14 @@ append_options(char *mntopts, char *newopts)
73397339
static enum sa_protocol
73407340
sa_protocol_decode(const char *protocol)
73417341
{
7342-
for (enum sa_protocol i = 0; i < ARRAY_SIZE(sa_protocol_names); ++i)
7343-
if (strcmp(protocol, sa_protocol_names[i]) == 0)
7342+
for (enum sa_protocol i = 0; i < SA_PROTOCOL_COUNT; ++i)
7343+
if (strcmp(protocol, zfs_share_protocol_name(i)) == 0)
73447344
return (i);
73457345

73467346
(void) fputs(gettext("share type must be one of: "), stderr);
7347-
for (enum sa_protocol i = 0;
7348-
i < ARRAY_SIZE(sa_protocol_names); ++i)
7347+
for (enum sa_protocol i = 0; i < SA_PROTOCOL_COUNT; ++i)
73497348
(void) fprintf(stderr, "%s%s",
7350-
i != 0 ? ", " : "", sa_protocol_names[i]);
7349+
i != 0 ? ", " : "", zfs_share_protocol_name(i));
73517350
(void) fputc('\n', stderr);
73527351
usage(B_FALSE);
73537352
}

include/libzfs.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#define _LIBZFS_H extern __attribute__((visibility("default")))
3838

3939
#include <assert.h>
40-
#include <libshare.h>
4140
#include <libnvpair.h>
4241
#include <sys/mnttab.h>
4342
#include <sys/param.h>
@@ -983,6 +982,15 @@ _LIBZFS_H void zfs_adjust_mount_options(zfs_handle_t *zhp, const char *mntpoint,
983982
*/
984983
#define SA_NO_PROTOCOL -1
985984

985+
/* available protocols */
986+
enum sa_protocol {
987+
SA_PROTOCOL_NFS,
988+
SA_PROTOCOL_SMB, /* ABI: add before _COUNT */
989+
SA_PROTOCOL_COUNT,
990+
};
991+
992+
_LIBZFS_H const char *zfs_share_protocol_name(enum sa_protocol);
993+
986994
_LIBZFS_H boolean_t zfs_is_shared(zfs_handle_t *zhp, char **where,
987995
const enum sa_protocol *proto);
988996
_LIBZFS_H int zfs_share(zfs_handle_t *zhp, const enum sa_protocol *proto);

lib/Makefile.am

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
# |--libzdb--zdb | |
1717
# | | |
1818
# libzpool libzfs* ----------------+
19-
# | | | \ / | | |\
20-
# libicp --/ | | \ / | \ | \----- libshare
21-
# | | \ / | \ \
22-
# libzstd ---/ | \ / | \ \-------\
23-
# | \ / \ \ \
24-
# libunicode --/ \ / \ \-------\ \
19+
# | | \ / | | |
20+
# libicp --/ | \ / | \ |
21+
# | \ / | \ \
22+
# libzstd ---/ \ / | \ \-------\
23+
# \ / \ \ \
24+
# \ / \ \-------\ \
2525
# \ / \ \ |
2626
# libzutil libzfs_core* | |
2727
# | | | \ | | | |
@@ -56,7 +56,6 @@ pkgconfig_DATA =
5656
include $(srcdir)/%D%/libavl/Makefile.am
5757
include $(srcdir)/%D%/libicp/Makefile.am
5858
include $(srcdir)/%D%/libnvpair/Makefile.am
59-
include $(srcdir)/%D%/libshare/Makefile.am
6059
include $(srcdir)/%D%/libspl/Makefile.am
6160
include $(srcdir)/%D%/libunicode/Makefile.am
6261
include $(srcdir)/%D%/libzdb/Makefile.am

lib/libshare/Makefile.am

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/libshare/libshare_impl.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

lib/libshare/nfs.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

lib/libshare/smb.h

Lines changed: 0 additions & 46 deletions
This file was deleted.

lib/libspl/include/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ libspl_HEADERS = \
33
%D%/assert.h \
44
%D%/atomic.h \
55
%D%/libgen.h \
6-
%D%/libshare.h \
76
%D%/libspl.h \
87
%D%/statcommon.h \
98
%D%/stdlib.h \

lib/libzfs/Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CPPCHECKTARGETS += libzfs.la
77

88
dist_libzfs_la_SOURCES = \
99
%D%/libzfs_impl.h \
10+
%D%/libzfs_share.h \
1011
%D%/libzfs_changelist.c \
1112
%D%/libzfs_config.c \
1213
%D%/libzfs_crypto.c \
@@ -16,20 +17,26 @@ dist_libzfs_la_SOURCES = \
1617
%D%/libzfs_iter.c \
1718
%D%/libzfs_mount.c \
1819
%D%/libzfs_pool.c \
20+
%D%/libzfs_share.c \
21+
%D%/libzfs_share_nfs.c \
1922
%D%/libzfs_sendrecv.c \
2023
%D%/libzfs_status.c \
2124
%D%/libzfs_util.c
2225

2326
if BUILD_FREEBSD
2427
dist_libzfs_la_SOURCES += \
2528
%D%/os/freebsd/libzfs_compat.c \
29+
%D%/os/freebsd/libzfs_share_nfs.c \
30+
%D%/os/freebsd/libzfs_share_smb.c \
2631
%D%/os/freebsd/libzfs_zmount.c
2732
endif
2833

2934
if BUILD_LINUX
3035
dist_libzfs_la_SOURCES += \
3136
%D%/os/linux/libzfs_mount_os.c \
3237
%D%/os/linux/libzfs_pool_os.c \
38+
%D%/os/linux/libzfs_share_nfs.c \
39+
%D%/os/linux/libzfs_share_smb.c \
3340
%D%/os/linux/libzfs_util_os.c
3441
endif
3542

@@ -52,7 +59,6 @@ nodist_libzfs_la_SOURCES = \
5259
module/zcommon/zprop_common.c
5360

5461
libzfs_la_LIBADD = \
55-
libshare.la \
5662
libzfs_core.la \
5763
libnvpair.la \
5864
libzutil.la

0 commit comments

Comments
 (0)