nfs4acl.c (bcaab953b1d3790c724a211f2452b574fd49a7ce) | nfs4acl.c (35e634b83cbe23e5673289d1536752968aab8f75) |
---|---|
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> --- 132 unchanged lines hidden (view full) --- 141{ 142 struct inode *inode = dentry->d_inode; 143 int error = 0; 144 struct posix_acl *pacl = NULL, *dpacl = NULL; 145 unsigned int flags = 0; 146 int size = 0; 147 148 pacl = get_acl(inode, ACL_TYPE_ACCESS); | 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> --- 132 unchanged lines hidden (view full) --- 141{ 142 struct inode *inode = dentry->d_inode; 143 int error = 0; 144 struct posix_acl *pacl = NULL, *dpacl = NULL; 145 unsigned int flags = 0; 146 int size = 0; 147 148 pacl = get_acl(inode, ACL_TYPE_ACCESS); |
149 if (!pacl) { | 149 if (!pacl) |
150 pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); | 150 pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); |
151 if (IS_ERR(pacl)) 152 return PTR_ERR(pacl); 153 } | 151 152 if (IS_ERR(pacl)) 153 return PTR_ERR(pacl); 154 |
154 /* allocate for worst case: one (deny, allow) pair each: */ 155 size += 2 * pacl->a_count; 156 157 if (S_ISDIR(inode->i_mode)) { 158 flags = NFS4_ACL_DIR; 159 dpacl = get_acl(inode, ACL_TYPE_DEFAULT); | 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 (IS_ERR(dpacl)) { 162 error = PTR_ERR(dpacl); 163 goto rel_pacl; 164 } 165 |
|
160 if (dpacl) 161 size += 2 * dpacl->a_count; 162 } 163 164 *acl = kmalloc(nfs4_acl_bytes(size), GFP_KERNEL); 165 if (*acl == NULL) { 166 error = -ENOMEM; 167 goto out; 168 } 169 (*acl)->naces = 0; 170 171 _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT); 172 173 if (dpacl) 174 _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT); 175 | 166 if (dpacl) 167 size += 2 * dpacl->a_count; 168 } 169 170 *acl = kmalloc(nfs4_acl_bytes(size), GFP_KERNEL); 171 if (*acl == NULL) { 172 error = -ENOMEM; 173 goto out; 174 } 175 (*acl)->naces = 0; 176 177 _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT); 178 179 if (dpacl) 180 _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT); 181 |
176 out: 177 posix_acl_release(pacl); | 182out: |
178 posix_acl_release(dpacl); | 183 posix_acl_release(dpacl); |
184rel_pacl: 185 posix_acl_release(pacl); |
|
179 return error; 180} 181 182struct posix_acl_summary { 183 unsigned short owner; 184 unsigned short users; 185 unsigned short group; 186 unsigned short groups; --- 751 unchanged lines hidden --- | 186 return error; 187} 188 189struct posix_acl_summary { 190 unsigned short owner; 191 unsigned short users; 192 unsigned short group; 193 unsigned short groups; --- 751 unchanged lines hidden --- |