Deleted Added
full compact
zfs_iter.c (219089) zfs_iter.c (230438)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 6 unchanged lines hidden (view full) ---

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 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 6 unchanged lines hidden (view full) ---

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 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
24 * All rights reserved.
23 */
24
25#include <libintl.h>
26#include <libuutil.h>
27#include <stddef.h>
28#include <stdio.h>
29#include <stdlib.h>
30#include <strings.h>

--- 93 unchanged lines hidden (view full) ---

124 * Recurse if necessary.
125 */
126 if (cb->cb_flags & ZFS_ITER_RECURSE &&
127 ((cb->cb_flags & ZFS_ITER_DEPTH_LIMIT) == 0 ||
128 cb->cb_depth < cb->cb_depth_limit)) {
129 cb->cb_depth++;
130 if (zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM)
131 (void) zfs_iter_filesystems(zhp, zfs_callback, data);
25 */
26
27#include <libintl.h>
28#include <libuutil.h>
29#include <stddef.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <strings.h>

--- 93 unchanged lines hidden (view full) ---

126 * Recurse if necessary.
127 */
128 if (cb->cb_flags & ZFS_ITER_RECURSE &&
129 ((cb->cb_flags & ZFS_ITER_DEPTH_LIMIT) == 0 ||
130 cb->cb_depth < cb->cb_depth_limit)) {
131 cb->cb_depth++;
132 if (zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM)
133 (void) zfs_iter_filesystems(zhp, zfs_callback, data);
132 if ((zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT) && include_snaps)
133 (void) zfs_iter_snapshots(zhp, zfs_callback, data);
134 if ((zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT) && include_snaps) {
135 (void) zfs_iter_snapshots(zhp,
136 (cb->cb_flags & ZFS_ITER_SIMPLE) != 0, zfs_callback,
137 data);
138 }
134 cb->cb_depth--;
135 }
136
137 if (!dontclose)
138 zfs_close(zhp);
139
140 return (0);
141}

--- 37 unchanged lines hidden (view full) ---

179 while (sc != NULL) {
180 col = sc->sc_next;
181 free(sc->sc_user_prop);
182 free(sc);
183 sc = col;
184 }
185}
186
139 cb->cb_depth--;
140 }
141
142 if (!dontclose)
143 zfs_close(zhp);
144
145 return (0);
146}

--- 37 unchanged lines hidden (view full) ---

184 while (sc != NULL) {
185 col = sc->sc_next;
186 free(sc->sc_user_prop);
187 free(sc);
188 sc = col;
189 }
190}
191
192boolean_t
193zfs_sort_only_by_name(const zfs_sort_column_t *sc)
194{
195
196 return (sc != NULL && sc->sc_next == NULL &&
197 sc->sc_prop == ZFS_PROP_NAME);
198}
199
187/* ARGSUSED */
188static int
189zfs_compare(const void *larg, const void *rarg, void *unused)
190{
191 zfs_handle_t *l = ((zfs_node_t *)larg)->zn_handle;
192 zfs_handle_t *r = ((zfs_node_t *)rarg)->zn_handle;
193 const char *lname = zfs_get_name(l);
194 const char *rname = zfs_get_name(r);

--- 24 unchanged lines hidden (view full) ---

219 * If we have two snapshots from the same dataset, then
220 * we want to sort them according to creation time. We
221 * use the hidden CREATETXG property to get an absolute
222 * ordering of snapshots.
223 */
224 lcreate = zfs_prop_get_int(l, ZFS_PROP_CREATETXG);
225 rcreate = zfs_prop_get_int(r, ZFS_PROP_CREATETXG);
226
200/* ARGSUSED */
201static int
202zfs_compare(const void *larg, const void *rarg, void *unused)
203{
204 zfs_handle_t *l = ((zfs_node_t *)larg)->zn_handle;
205 zfs_handle_t *r = ((zfs_node_t *)rarg)->zn_handle;
206 const char *lname = zfs_get_name(l);
207 const char *rname = zfs_get_name(r);

--- 24 unchanged lines hidden (view full) ---

232 * If we have two snapshots from the same dataset, then
233 * we want to sort them according to creation time. We
234 * use the hidden CREATETXG property to get an absolute
235 * ordering of snapshots.
236 */
237 lcreate = zfs_prop_get_int(l, ZFS_PROP_CREATETXG);
238 rcreate = zfs_prop_get_int(r, ZFS_PROP_CREATETXG);
239
227 if (lcreate < rcreate)
240 /*
241 * Both lcreate and rcreate being 0 means we don't have
242 * properties and we should compare full name.
243 */
244 if (lcreate == 0 && rcreate == 0)
245 ret = strcmp(lat + 1, rat + 1);
246 else if (lcreate < rcreate)
228 ret = -1;
229 else if (lcreate > rcreate)
230 ret = 1;
231 }
232 }
233
234 if (lat != NULL)
235 *lat = '@';

--- 49 unchanged lines hidden (view full) ---

285 psc->sc_user_prop, &rval) == 0);
286
287 if (lvalid)
288 verify(nvlist_lookup_string(lval,
289 ZPROP_VALUE, &lstr) == 0);
290 if (rvalid)
291 verify(nvlist_lookup_string(rval,
292 ZPROP_VALUE, &rstr) == 0);
247 ret = -1;
248 else if (lcreate > rcreate)
249 ret = 1;
250 }
251 }
252
253 if (lat != NULL)
254 *lat = '@';

--- 49 unchanged lines hidden (view full) ---

304 psc->sc_user_prop, &rval) == 0);
305
306 if (lvalid)
307 verify(nvlist_lookup_string(lval,
308 ZPROP_VALUE, &lstr) == 0);
309 if (rvalid)
310 verify(nvlist_lookup_string(rval,
311 ZPROP_VALUE, &rstr) == 0);
312 } else if (psc->sc_prop == ZFS_PROP_NAME) {
313 lvalid = rvalid = B_TRUE;
293
314
315 (void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf));
316 (void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf));
317
318 lstr = lbuf;
319 rstr = rbuf;
294 } else if (zfs_prop_is_string(psc->sc_prop)) {
295 lvalid = (zfs_prop_get(l, psc->sc_prop, lbuf,
296 sizeof (lbuf), NULL, NULL, 0, B_TRUE) == 0);
297 rvalid = (zfs_prop_get(r, psc->sc_prop, rbuf,
298 sizeof (rbuf), NULL, NULL, 0, B_TRUE) == 0);
299
300 lstr = lbuf;
301 rstr = rbuf;

--- 163 unchanged lines hidden ---
320 } else if (zfs_prop_is_string(psc->sc_prop)) {
321 lvalid = (zfs_prop_get(l, psc->sc_prop, lbuf,
322 sizeof (lbuf), NULL, NULL, 0, B_TRUE) == 0);
323 rvalid = (zfs_prop_get(r, psc->sc_prop, rbuf,
324 sizeof (rbuf), NULL, NULL, 0, B_TRUE) == 0);
325
326 lstr = lbuf;
327 rstr = rbuf;

--- 163 unchanged lines hidden ---