author | Mark Shellenbaum <Mark.Shellenbaum@Sun.COM> |
Tue, 16 Mar 2010 09:43:38 -0600 | |
changeset 11935 | 538c866aaac6 |
parent 11876 | 5fce03ad05c6 |
child 13055 | 8c712bbb18ea |
permissions | -rw-r--r-- |
789 | 1 |
/* |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
2 |
* CDDL HEADER SART |
789 | 3 |
* |
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
3126 | 21 |
|
789 | 22 |
/* |
11876
5fce03ad05c6
PSARC/2010/006 EOF of iSCSI Target Daemon
Jim Dunham <James.Dunham@Sun.COM>
parents:
11022
diff
changeset
|
23 |
* Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
789 | 24 |
* Use is subject to license terms. |
25 |
*/ |
|
26 |
||
27 |
#ifndef _LIBFS_IMPL_H |
|
28 |
#define _LIBFS_IMPL_H |
|
29 |
||
30 |
#include <sys/dmu.h> |
|
31 |
#include <sys/fs/zfs.h> |
|
32 |
#include <sys/zfs_ioctl.h> |
|
4543 | 33 |
#include <sys/spa.h> |
789 | 34 |
#include <sys/nvpair.h> |
35 |
||
2082 | 36 |
#include <libuutil.h> |
789 | 37 |
#include <libzfs.h> |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
38 |
#include <libshare.h> |
789 | 39 |
|
10817
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
40 |
#include <fm/libtopo.h> |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
41 |
|
789 | 42 |
#ifdef __cplusplus |
43 |
extern "C" { |
|
44 |
#endif |
|
45 |
||
6442
b629b4fb30ca
6662212 libzfs should have a #define for VERIFY to assist backporting
gw25295
parents:
6423
diff
changeset
|
46 |
#ifdef VERIFY |
b629b4fb30ca
6662212 libzfs should have a #define for VERIFY to assist backporting
gw25295
parents:
6423
diff
changeset
|
47 |
#undef VERIFY |
b629b4fb30ca
6662212 libzfs should have a #define for VERIFY to assist backporting
gw25295
parents:
6423
diff
changeset
|
48 |
#endif |
b629b4fb30ca
6662212 libzfs should have a #define for VERIFY to assist backporting
gw25295
parents:
6423
diff
changeset
|
49 |
#define VERIFY verify |
b629b4fb30ca
6662212 libzfs should have a #define for VERIFY to assist backporting
gw25295
parents:
6423
diff
changeset
|
50 |
|
10817
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
51 |
typedef struct libzfs_fru { |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
52 |
char *zf_device; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
53 |
char *zf_fru; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
54 |
struct libzfs_fru *zf_chain; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
55 |
struct libzfs_fru *zf_next; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
56 |
} libzfs_fru_t; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
57 |
|
2082 | 58 |
struct libzfs_handle { |
59 |
int libzfs_error; |
|
60 |
int libzfs_fd; |
|
61 |
FILE *libzfs_mnttab; |
|
62 |
FILE *libzfs_sharetab; |
|
6865 | 63 |
zpool_handle_t *libzfs_pool_handles; |
2082 | 64 |
uu_avl_pool_t *libzfs_ns_avlpool; |
65 |
uu_avl_t *libzfs_ns_avl; |
|
66 |
uint64_t libzfs_ns_gen; |
|
67 |
int libzfs_desc_active; |
|
68 |
char libzfs_action[1024]; |
|
69 |
char libzfs_desc[1024]; |
|
4543 | 70 |
char *libzfs_log_str; |
2082 | 71 |
int libzfs_printerr; |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
72 |
void *libzfs_sharehdl; /* libshare handle */ |
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
73 |
uint_t libzfs_shareflags; |
8811
f8deccf701cf
6790687 libzfs mnttab caching ignores external changes
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
8802
diff
changeset
|
74 |
boolean_t libzfs_mnttab_enable; |
8228
51e9ca9ee3a5
6572357 libzfs should do more to avoid mnttab lookups
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7366
diff
changeset
|
75 |
avl_tree_t libzfs_mnttab_cache; |
10817
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
76 |
int libzfs_pool_iter; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
77 |
topo_hdl_t *libzfs_topo_hdl; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
78 |
libzfs_fru_t **libzfs_fru_hash; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
79 |
libzfs_fru_t *libzfs_fru_list; |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
80 |
char libzfs_chassis_id[256]; |
2082 | 81 |
}; |
10817
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
82 |
|
5951
c597da46efd6
6558321 zfs_share_nfs() fails the second time through
dougm
parents:
5367
diff
changeset
|
83 |
#define ZFSSHARE_MISS 0x01 /* Didn't find entry in cache */ |
2082 | 84 |
|
789 | 85 |
struct zfs_handle { |
2082 | 86 |
libzfs_handle_t *zfs_hdl; |
6865 | 87 |
zpool_handle_t *zpool_hdl; |
789 | 88 |
char zfs_name[ZFS_MAXNAMELEN]; |
2885 | 89 |
zfs_type_t zfs_type; /* type including snapshot */ |
90 |
zfs_type_t zfs_head_type; /* type excluding snapshot */ |
|
789 | 91 |
dmu_objset_stats_t zfs_dmustats; |
1356
e021b5e4aa0e
6377671 zfs mount -a shouldn't bother checking snapshots
eschrock
parents:
1294
diff
changeset
|
92 |
nvlist_t *zfs_props; |
2676 | 93 |
nvlist_t *zfs_user_props; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10817
diff
changeset
|
94 |
nvlist_t *zfs_recvd_props; |
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2142
diff
changeset
|
95 |
boolean_t zfs_mntcheck; |
789 | 96 |
char *zfs_mntopts; |
8802
010b31dd4c53
6773366 "zfs list" memory consumption can be further reduced
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
8228
diff
changeset
|
97 |
uint8_t *zfs_props_table; |
789 | 98 |
}; |
99 |
||
2676 | 100 |
/* |
101 |
* This is different from checking zfs_type, because it will also catch |
|
102 |
* snapshots of volumes. |
|
103 |
*/ |
|
2885 | 104 |
#define ZFS_IS_VOLUME(zhp) ((zhp)->zfs_head_type == ZFS_TYPE_VOLUME) |
2676 | 105 |
|
789 | 106 |
struct zpool_handle { |
2082 | 107 |
libzfs_handle_t *zpool_hdl; |
6865 | 108 |
zpool_handle_t *zpool_next; |
789 | 109 |
char zpool_name[ZPOOL_MAXNAMELEN]; |
110 |
int zpool_state; |
|
111 |
size_t zpool_config_size; |
|
112 |
nvlist_t *zpool_config; |
|
952
12ec54aa046e
6344502 placeholder bug for the remaining Makefile cleanup work for ZFS
eschrock
parents:
789
diff
changeset
|
113 |
nvlist_t *zpool_old_config; |
3912 | 114 |
nvlist_t *zpool_props; |
4276
c42d49ffb16f
6385547 zpool create of a mirror using a device and a slice of a device (of same size) reports an error
taylor
parents:
4180
diff
changeset
|
115 |
diskaddr_t zpool_start_block; |
789 | 116 |
}; |
117 |
||
5331 | 118 |
typedef enum { |
119 |
PROTO_NFS = 0, |
|
120 |
PROTO_SMB = 1, |
|
121 |
PROTO_END = 2 |
|
122 |
} zfs_share_proto_t; |
|
123 |
||
124 |
/* |
|
125 |
* The following can be used as a bitmask and any new values |
|
126 |
* added must preserve that capability. |
|
127 |
*/ |
|
128 |
typedef enum { |
|
129 |
SHARED_NOT_SHARED = 0x0, |
|
130 |
SHARED_NFS = 0x2, |
|
131 |
SHARED_SMB = 0x4 |
|
132 |
} zfs_share_type_t; |
|
133 |
||
3237
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3126
diff
changeset
|
134 |
int zfs_error(libzfs_handle_t *, int, const char *); |
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3126
diff
changeset
|
135 |
int zfs_error_fmt(libzfs_handle_t *, int, const char *, ...); |
2082 | 136 |
void zfs_error_aux(libzfs_handle_t *, const char *, ...); |
137 |
void *zfs_alloc(libzfs_handle_t *, size_t); |
|
2676 | 138 |
void *zfs_realloc(libzfs_handle_t *, void *, size_t, size_t); |
2082 | 139 |
char *zfs_strdup(libzfs_handle_t *, const char *); |
140 |
int no_memory(libzfs_handle_t *); |
|
789 | 141 |
|
3237
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3126
diff
changeset
|
142 |
int zfs_standard_error(libzfs_handle_t *, int, const char *); |
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3126
diff
changeset
|
143 |
int zfs_standard_error_fmt(libzfs_handle_t *, int, const char *, ...); |
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3126
diff
changeset
|
144 |
int zpool_standard_error(libzfs_handle_t *, int, const char *); |
98d0c28f2f5e
6480245 renaming a dataset to something with '%s' will cause segfault
lling
parents:
3126
diff
changeset
|
145 |
int zpool_standard_error_fmt(libzfs_handle_t *, int, const char *, ...); |
789 | 146 |
|
2474
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2142
diff
changeset
|
147 |
int get_dependents(libzfs_handle_t *, boolean_t, const char *, char ***, |
c001ad7e0c25
6368751 libzfs interface for mount/umounting all the file systems for a given pool
eschrock
parents:
2142
diff
changeset
|
148 |
size_t *); |
789 | 149 |
|
3912 | 150 |
|
5094 | 151 |
int zprop_parse_value(libzfs_handle_t *, nvpair_t *, int, zfs_type_t, |
152 |
nvlist_t *, char **, uint64_t *, const char *); |
|
153 |
int zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp, |
|
154 |
zfs_type_t type); |
|
3912 | 155 |
|
7366
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
156 |
/* |
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
157 |
* Use this changelist_gather() flag to force attempting mounts |
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
158 |
* on each change node regardless of whether or not it is currently |
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
159 |
* mounted. |
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
160 |
*/ |
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
161 |
#define CL_GATHER_MOUNT_ALWAYS 1 |
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
162 |
|
789 | 163 |
typedef struct prop_changelist prop_changelist_t; |
164 |
||
2676 | 165 |
int zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t); |
5094 | 166 |
int zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *); |
167 |
int zcmd_write_conf_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *); |
|
2676 | 168 |
int zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *); |
169 |
int zcmd_read_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t **); |
|
170 |
void zcmd_free_nvlists(zfs_cmd_t *); |
|
171 |
||
789 | 172 |
int changelist_prefix(prop_changelist_t *); |
173 |
int changelist_postfix(prop_changelist_t *); |
|
174 |
void changelist_rename(prop_changelist_t *, const char *, const char *); |
|
5367 | 175 |
void changelist_remove(prop_changelist_t *, const char *); |
789 | 176 |
void changelist_free(prop_changelist_t *); |
7366
33de5956afbb
6678308 zfs receive dumps core when -n is used, fails on replication stream
Tim Haley <Tim.Haley@Sun.COM>
parents:
6865
diff
changeset
|
177 |
prop_changelist_t *changelist_gather(zfs_handle_t *, zfs_prop_t, int, int); |
5331 | 178 |
int changelist_unshare(prop_changelist_t *, zfs_share_proto_t *); |
789 | 179 |
int changelist_haszonedchild(prop_changelist_t *); |
180 |
||
181 |
void remove_mountpoint(zfs_handle_t *); |
|
5367 | 182 |
int create_parents(libzfs_handle_t *, char *, int); |
6027
68b03551f113
6609196 'zfs destroy -r' can needlessly iterate over all filesystems in pool
rm160521
parents:
5951
diff
changeset
|
183 |
boolean_t isa_child_of(const char *dataset, const char *parent); |
789 | 184 |
|
2082 | 185 |
zfs_handle_t *make_dataset_handle(libzfs_handle_t *, const char *); |
1544 | 186 |
|
2142
f6e0487aa9a3
6433264 crash when adding spare: nvlist_lookup_string(cnv, "path", &path) == 0
eschrock
parents:
2082
diff
changeset
|
187 |
int zpool_open_silent(libzfs_handle_t *, const char *, zpool_handle_t **); |
789 | 188 |
|
6423 | 189 |
boolean_t zpool_name_valid(libzfs_handle_t *, boolean_t, const char *); |
789 | 190 |
|
2082 | 191 |
void namespace_clear(libzfs_handle_t *); |
789 | 192 |
|
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
193 |
/* |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
194 |
* libshare (sharemgr) interfaces used internally. |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
195 |
*/ |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
196 |
|
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
197 |
extern int zfs_init_libshare(libzfs_handle_t *, int); |
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
198 |
extern void zfs_uninit_libshare(libzfs_handle_t *); |
5331 | 199 |
extern int zfs_parse_options(char *, zfs_share_proto_t); |
4180
30b15f0bd3c9
6491973 sharemgr: zfs set sharenfs=on is slow with lots of zfs filesystems
dougm
parents:
3912
diff
changeset
|
200 |
|
8845
91af0d9c0790
6800942 smb_session_create() incorrectly stores IP addresses
Alan Wright <amw@Sun.COM>
parents:
8811
diff
changeset
|
201 |
extern int zfs_unshare_proto(zfs_handle_t *, |
5331 | 202 |
const char *, zfs_share_proto_t *); |
10817
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
203 |
|
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
204 |
extern void libzfs_fru_clear(libzfs_handle_t *, boolean_t); |
7dfde45252f0
6889826 ZFS retire agent should be able to repair pools
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10588
diff
changeset
|
205 |
|
789 | 206 |
#ifdef __cplusplus |
207 |
} |
|
208 |
#endif |
|
209 |
||
210 |
#endif /* _LIBFS_IMPL_H */ |