Deleted Added
sdiff udiff text old ( 303970 ) new ( 321545 )
full compact
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

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

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 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
24 */
25
26#include <sys/types.h>
27#include <sys/param.h>
28#include <sys/time.h>
29#include <sys/systm.h>
30#include <sys/sysmacros.h>
31#include <sys/resource.h>

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

58#include <sys/extdirent.h>
59
60/*
61 * zfs_match_find() is used by zfs_dirent_lookup() to peform zap lookups
62 * of names after deciding which is the appropriate lookup interface.
63 */
64static int
65zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, const char *name,
66 boolean_t exact, uint64_t *zoid)
67{
68 int error;
69
70 if (zfsvfs->z_norm) {
71 matchtype_t mt = exact? MT_EXACT : MT_FIRST;
72
73 /*
74 * In the non-mixed case we only expect there would ever
75 * be one match, but we need to use the normalizing lookup.
76 */
77 error = zap_lookup_norm(zfsvfs->z_os, dzp->z_id, name, 8, 1,
78 zoid, mt, NULL, 0, NULL);
79 } else {

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

103 * Return value: 0 on success or errno on failure.
104 *
105 * NOTE: Always checks for, and rejects, '.' and '..'.
106 */
107int
108zfs_dirent_lookup(znode_t *dzp, const char *name, znode_t **zpp, int flag)
109{
110 zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
111 boolean_t exact;
112 uint64_t zoid;
113 vnode_t *vp = NULL;
114 int error = 0;
115
116 ASSERT_VOP_LOCKED(ZTOV(dzp), __func__);
117
118 *zpp = NULL;
119

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

126 return (SET_ERROR(EEXIST));
127
128 /*
129 * Case sensitivity and normalization preferences are set when
130 * the file system is created. These are stored in the
131 * zfsvfs->z_case and zfsvfs->z_norm fields. These choices
132 * affect how we perform zap lookups.
133 *
134 * Decide if exact matches should be requested when performing
135 * a zap lookup on file systems supporting case-insensitive
136 * access.
137 *
138 * NB: we do not need to worry about this flag for ZFS_CASE_SENSITIVE
139 * because in that case MT_EXACT and MT_FIRST should produce exactly
140 * the same result.
141 */
142 exact = zfsvfs->z_case == ZFS_CASE_MIXED;
143
144 if (dzp->z_unlinked && !(flag & ZXATTR))
145 return (ENOENT);
146 if (flag & ZXATTR) {
147 error = sa_lookup(dzp->z_sa_hdl, SA_ZPL_XATTR(zfsvfs), &zoid,
148 sizeof (zoid));
149 if (error == 0)
150 error = (zoid == 0 ? ENOENT : 0);
151 } else {
152 error = zfs_match_find(zfsvfs, dzp, name, exact, &zoid);
153 }
154 if (error) {
155 if (error != ENOENT || (flag & ZEXISTS)) {
156 return (error);
157 }
158 } else {
159 if (flag & ZNEW) {
160 return (SET_ERROR(EEXIST));

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

561 value = zfs_dirent(zp, zp->z_mode);
562 error = zap_add(zp->z_zfsvfs->z_os, dzp->z_id, name,
563 8, 1, &value, tx);
564 VERIFY0(error);
565
566 return (0);
567}
568
569static int
570zfs_dropname(znode_t *dzp, const char *name, znode_t *zp, dmu_tx_t *tx,
571 int flag)
572{
573 int error;
574
575 if (zp->z_zfsvfs->z_norm) {
576 if (zp->z_zfsvfs->z_case == ZFS_CASE_MIXED)
577 error = zap_remove_norm(zp->z_zfsvfs->z_os,
578 dzp->z_id, name, MT_EXACT, tx);
579 else
580 error = zap_remove_norm(zp->z_zfsvfs->z_os,
581 dzp->z_id, name, MT_FIRST, tx);
582 } else {
583 error = zap_remove(zp->z_zfsvfs->z_os,
584 dzp->z_id, name, tx);
585 }
586
587 return (error);
588}
589
590/*
591 * Unlink zp from dzp, and mark zp for deletion if this was the last link.
592 * Can fail if zp is a mount point (EBUSY) or a non-empty directory (EEXIST).

--- 284 unchanged lines hidden ---