nfs4acl.c (3c3d7cb1db4af176dab843f22ea092a4ef1eb989) nfs4acl.c (09bdc2d70dedd0fc0358da93bca664c7b11ff907)
1/*
2 * Common NFSv4 ACL handling code.
3 *
4 * Copyright (c) 2002, 2003 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Marius Aamodt Eriksen <marius@umich.edu>
8 * Jeff Sedlak <jsedlak@umich.edu>

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

146 unsigned int flags = 0;
147 int size = 0;
148
149 pacl = get_acl(inode, ACL_TYPE_ACCESS);
150 if (!pacl) {
151 pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
152 if (IS_ERR(pacl))
153 return PTR_ERR(pacl);
1/*
2 * Common NFSv4 ACL handling code.
3 *
4 * Copyright (c) 2002, 2003 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Marius Aamodt Eriksen <marius@umich.edu>
8 * Jeff Sedlak <jsedlak@umich.edu>

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

146 unsigned int flags = 0;
147 int size = 0;
148
149 pacl = get_acl(inode, ACL_TYPE_ACCESS);
150 if (!pacl) {
151 pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
152 if (IS_ERR(pacl))
153 return PTR_ERR(pacl);
154 /* allocate for worst case: one (deny, allow) pair each: */
155 size += 2 * pacl->a_count;
156 }
154 }
155 /* allocate for worst case: one (deny, allow) pair each: */
156 size += 2 * pacl->a_count;
157
158 if (S_ISDIR(inode->i_mode)) {
159 flags = NFS4_ACL_DIR;
160 dpacl = get_acl(inode, ACL_TYPE_DEFAULT);
161 if (dpacl)
162 size += 2 * dpacl->a_count;
157
158 if (S_ISDIR(inode->i_mode)) {
159 flags = NFS4_ACL_DIR;
160 dpacl = get_acl(inode, ACL_TYPE_DEFAULT);
161 if (dpacl)
162 size += 2 * dpacl->a_count;
163 } else {
164 dpacl = NULL;
165 }
166
167 *acl = nfs4_acl_new(size);
168 if (*acl == NULL) {
169 error = -ENOMEM;
170 goto out;
171 }
172
163 }
164
165 *acl = nfs4_acl_new(size);
166 if (*acl == NULL) {
167 error = -ENOMEM;
168 goto out;
169 }
170
173 if (pacl)
174 _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
171 _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
175
176 if (dpacl)
177 _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT);
178
179 out:
180 posix_acl_release(pacl);
181 posix_acl_release(dpacl);
182 return error;

--- 756 unchanged lines hidden ---
172
173 if (dpacl)
174 _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT);
175
176 out:
177 posix_acl_release(pacl);
178 posix_acl_release(dpacl);
179 return error;

--- 756 unchanged lines hidden ---