Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 2 | /* |
| 3 | * (C) 2001 Clemson University and The University of Chicago |
| 4 | * |
| 5 | * See COPYING in top-level directory. |
| 6 | */ |
Jérémy Lefaure | 296200d | 2017-10-01 15:30:48 -0400 | [diff] [blame] | 7 | #include <linux/kernel.h> |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 8 | #include "protocol.h" |
Mike Marshall | 575e946 | 2015-12-04 12:56:14 -0500 | [diff] [blame] | 9 | #include "orangefs-kernel.h" |
| 10 | #include "orangefs-dev-proto.h" |
| 11 | #include "orangefs-bufmap.h" |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 12 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 13 | __s32 fsid_of_op(struct orangefs_kernel_op_s *op) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 14 | { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 15 | __s32 fsid = ORANGEFS_FS_ID_NULL; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 16 | |
| 17 | if (op) { |
| 18 | switch (op->upcall.type) { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 19 | case ORANGEFS_VFS_OP_FILE_IO: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 20 | fsid = op->upcall.req.io.refn.fs_id; |
| 21 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 22 | case ORANGEFS_VFS_OP_LOOKUP: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 23 | fsid = op->upcall.req.lookup.parent_refn.fs_id; |
| 24 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 25 | case ORANGEFS_VFS_OP_CREATE: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 26 | fsid = op->upcall.req.create.parent_refn.fs_id; |
| 27 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 28 | case ORANGEFS_VFS_OP_GETATTR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 29 | fsid = op->upcall.req.getattr.refn.fs_id; |
| 30 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 31 | case ORANGEFS_VFS_OP_REMOVE: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 32 | fsid = op->upcall.req.remove.parent_refn.fs_id; |
| 33 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 34 | case ORANGEFS_VFS_OP_MKDIR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 35 | fsid = op->upcall.req.mkdir.parent_refn.fs_id; |
| 36 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 37 | case ORANGEFS_VFS_OP_READDIR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 38 | fsid = op->upcall.req.readdir.refn.fs_id; |
| 39 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 40 | case ORANGEFS_VFS_OP_SETATTR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 41 | fsid = op->upcall.req.setattr.refn.fs_id; |
| 42 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 43 | case ORANGEFS_VFS_OP_SYMLINK: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 44 | fsid = op->upcall.req.sym.parent_refn.fs_id; |
| 45 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 46 | case ORANGEFS_VFS_OP_RENAME: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 47 | fsid = op->upcall.req.rename.old_parent_refn.fs_id; |
| 48 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 49 | case ORANGEFS_VFS_OP_STATFS: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 50 | fsid = op->upcall.req.statfs.fs_id; |
| 51 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 52 | case ORANGEFS_VFS_OP_TRUNCATE: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 53 | fsid = op->upcall.req.truncate.refn.fs_id; |
| 54 | break; |
Martin Brandenburg | 6eaff8c | 2016-08-02 14:31:05 -0400 | [diff] [blame] | 55 | case ORANGEFS_VFS_OP_RA_FLUSH: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 56 | fsid = op->upcall.req.ra_cache_flush.refn.fs_id; |
| 57 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 58 | case ORANGEFS_VFS_OP_FS_UMOUNT: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 59 | fsid = op->upcall.req.fs_umount.fs_id; |
| 60 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 61 | case ORANGEFS_VFS_OP_GETXATTR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 62 | fsid = op->upcall.req.getxattr.refn.fs_id; |
| 63 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 64 | case ORANGEFS_VFS_OP_SETXATTR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 65 | fsid = op->upcall.req.setxattr.refn.fs_id; |
| 66 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 67 | case ORANGEFS_VFS_OP_LISTXATTR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 68 | fsid = op->upcall.req.listxattr.refn.fs_id; |
| 69 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 70 | case ORANGEFS_VFS_OP_REMOVEXATTR: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 71 | fsid = op->upcall.req.removexattr.refn.fs_id; |
| 72 | break; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 73 | case ORANGEFS_VFS_OP_FSYNC: |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 74 | fsid = op->upcall.req.fsync.refn.fs_id; |
| 75 | break; |
| 76 | default: |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | return fsid; |
| 81 | } |
| 82 | |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 83 | static int orangefs_inode_flags(struct ORANGEFS_sys_attr_s *attrs) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 84 | { |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 85 | int flags = 0; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 86 | if (attrs->flags & ORANGEFS_IMMUTABLE_FL) |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 87 | flags |= S_IMMUTABLE; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 88 | else |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 89 | flags &= ~S_IMMUTABLE; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 90 | if (attrs->flags & ORANGEFS_APPEND_FL) |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 91 | flags |= S_APPEND; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 92 | else |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 93 | flags &= ~S_APPEND; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 94 | if (attrs->flags & ORANGEFS_NOATIME_FL) |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 95 | flags |= S_NOATIME; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 96 | else |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 97 | flags &= ~S_NOATIME; |
| 98 | return flags; |
| 99 | } |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 100 | |
Martin Brandenburg | 394f647 | 2016-01-25 15:33:39 -0500 | [diff] [blame] | 101 | static int orangefs_inode_perms(struct ORANGEFS_sys_attr_s *attrs) |
| 102 | { |
| 103 | int perm_mode = 0; |
| 104 | |
| 105 | if (attrs->perms & ORANGEFS_O_EXECUTE) |
| 106 | perm_mode |= S_IXOTH; |
| 107 | if (attrs->perms & ORANGEFS_O_WRITE) |
| 108 | perm_mode |= S_IWOTH; |
| 109 | if (attrs->perms & ORANGEFS_O_READ) |
| 110 | perm_mode |= S_IROTH; |
| 111 | |
| 112 | if (attrs->perms & ORANGEFS_G_EXECUTE) |
| 113 | perm_mode |= S_IXGRP; |
| 114 | if (attrs->perms & ORANGEFS_G_WRITE) |
| 115 | perm_mode |= S_IWGRP; |
| 116 | if (attrs->perms & ORANGEFS_G_READ) |
| 117 | perm_mode |= S_IRGRP; |
| 118 | |
| 119 | if (attrs->perms & ORANGEFS_U_EXECUTE) |
| 120 | perm_mode |= S_IXUSR; |
| 121 | if (attrs->perms & ORANGEFS_U_WRITE) |
| 122 | perm_mode |= S_IWUSR; |
| 123 | if (attrs->perms & ORANGEFS_U_READ) |
| 124 | perm_mode |= S_IRUSR; |
| 125 | |
| 126 | if (attrs->perms & ORANGEFS_G_SGID) |
| 127 | perm_mode |= S_ISGID; |
| 128 | if (attrs->perms & ORANGEFS_U_SUID) |
| 129 | perm_mode |= S_ISUID; |
| 130 | |
| 131 | return perm_mode; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 132 | } |
| 133 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 134 | /* |
| 135 | * NOTE: in kernel land, we never use the sys_attr->link_target for |
| 136 | * anything, so don't bother copying it into the sys_attr object here. |
| 137 | */ |
| 138 | static inline int copy_attributes_from_inode(struct inode *inode, |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 139 | struct ORANGEFS_sys_attr_s *attrs, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 140 | struct iattr *iattr) |
| 141 | { |
| 142 | umode_t tmp_mode; |
| 143 | |
| 144 | if (!iattr || !inode || !attrs) { |
| 145 | gossip_err("NULL iattr (%p), inode (%p), attrs (%p) " |
| 146 | "in copy_attributes_from_inode!\n", |
| 147 | iattr, |
| 148 | inode, |
| 149 | attrs); |
| 150 | return -EINVAL; |
| 151 | } |
| 152 | /* |
| 153 | * We need to be careful to only copy the attributes out of the |
| 154 | * iattr object that we know are valid. |
| 155 | */ |
| 156 | attrs->mask = 0; |
| 157 | if (iattr->ia_valid & ATTR_UID) { |
Jann Horn | 78fee0b | 2016-06-25 01:51:52 +0200 | [diff] [blame] | 158 | attrs->owner = from_kuid(&init_user_ns, iattr->ia_uid); |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 159 | attrs->mask |= ORANGEFS_ATTR_SYS_UID; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 160 | gossip_debug(GOSSIP_UTILS_DEBUG, "(UID) %d\n", attrs->owner); |
| 161 | } |
| 162 | if (iattr->ia_valid & ATTR_GID) { |
Jann Horn | 78fee0b | 2016-06-25 01:51:52 +0200 | [diff] [blame] | 163 | attrs->group = from_kgid(&init_user_ns, iattr->ia_gid); |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 164 | attrs->mask |= ORANGEFS_ATTR_SYS_GID; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 165 | gossip_debug(GOSSIP_UTILS_DEBUG, "(GID) %d\n", attrs->group); |
| 166 | } |
| 167 | |
| 168 | if (iattr->ia_valid & ATTR_ATIME) { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 169 | attrs->mask |= ORANGEFS_ATTR_SYS_ATIME; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 170 | if (iattr->ia_valid & ATTR_ATIME_SET) { |
Arnd Bergmann | be81ce4 | 2016-02-26 13:54:10 +0100 | [diff] [blame] | 171 | attrs->atime = (time64_t)iattr->ia_atime.tv_sec; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 172 | attrs->mask |= ORANGEFS_ATTR_SYS_ATIME_SET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | if (iattr->ia_valid & ATTR_MTIME) { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 176 | attrs->mask |= ORANGEFS_ATTR_SYS_MTIME; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 177 | if (iattr->ia_valid & ATTR_MTIME_SET) { |
Arnd Bergmann | be81ce4 | 2016-02-26 13:54:10 +0100 | [diff] [blame] | 178 | attrs->mtime = (time64_t)iattr->ia_mtime.tv_sec; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 179 | attrs->mask |= ORANGEFS_ATTR_SYS_MTIME_SET; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | if (iattr->ia_valid & ATTR_CTIME) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 183 | attrs->mask |= ORANGEFS_ATTR_SYS_CTIME; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 184 | |
| 185 | /* |
Mike Marshall | 95f5f88 | 2018-05-11 17:11:48 -0400 | [diff] [blame] | 186 | * ORANGEFS cannot set size with a setattr operation. Probably not |
| 187 | * likely to be requested through the VFS, but just in case, don't |
| 188 | * worry about ATTR_SIZE |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 189 | */ |
| 190 | |
| 191 | if (iattr->ia_valid & ATTR_MODE) { |
| 192 | tmp_mode = iattr->ia_mode; |
| 193 | if (tmp_mode & (S_ISVTX)) { |
| 194 | if (is_root_handle(inode)) { |
| 195 | /* |
| 196 | * allow sticky bit to be set on root (since |
| 197 | * it shows up that way by default anyhow), |
| 198 | * but don't show it to the server |
| 199 | */ |
| 200 | tmp_mode -= S_ISVTX; |
| 201 | } else { |
| 202 | gossip_debug(GOSSIP_UTILS_DEBUG, |
Mike Marshall | 95f5f88 | 2018-05-11 17:11:48 -0400 | [diff] [blame] | 203 | "%s: setting sticky bit not supported.\n", |
| 204 | __func__); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 205 | return -EINVAL; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | if (tmp_mode & (S_ISUID)) { |
| 210 | gossip_debug(GOSSIP_UTILS_DEBUG, |
Mike Marshall | 95f5f88 | 2018-05-11 17:11:48 -0400 | [diff] [blame] | 211 | "%s: setting setuid bit not supported.\n", |
| 212 | __func__); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 213 | return -EINVAL; |
| 214 | } |
| 215 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 216 | attrs->perms = ORANGEFS_util_translate_mode(tmp_mode); |
| 217 | attrs->mask |= ORANGEFS_ATTR_SYS_PERM; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | return 0; |
| 221 | } |
| 222 | |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 223 | static int orangefs_inode_type(enum orangefs_ds_type objtype) |
| 224 | { |
| 225 | if (objtype == ORANGEFS_TYPE_METAFILE) |
| 226 | return S_IFREG; |
| 227 | else if (objtype == ORANGEFS_TYPE_DIRECTORY) |
| 228 | return S_IFDIR; |
| 229 | else if (objtype == ORANGEFS_TYPE_SYMLINK) |
| 230 | return S_IFLNK; |
| 231 | else |
| 232 | return -1; |
| 233 | } |
| 234 | |
Martin Brandenburg | 4d0cac7 | 2018-01-26 14:07:14 -0500 | [diff] [blame] | 235 | static void orangefs_make_bad_inode(struct inode *inode) |
| 236 | { |
| 237 | if (is_root_handle(inode)) { |
| 238 | /* |
| 239 | * if this occurs, the pvfs2-client-core was killed but we |
| 240 | * can't afford to lose the inode operations and such |
| 241 | * associated with the root handle in any case. |
| 242 | */ |
| 243 | gossip_debug(GOSSIP_UTILS_DEBUG, |
| 244 | "*** NOT making bad root inode %pU\n", |
| 245 | get_khandle_from_ino(inode)); |
| 246 | } else { |
| 247 | gossip_debug(GOSSIP_UTILS_DEBUG, |
| 248 | "*** making bad inode %pU\n", |
| 249 | get_khandle_from_ino(inode)); |
| 250 | make_bad_inode(inode); |
| 251 | } |
| 252 | } |
| 253 | |
Martin Brandenburg | 480e5ae | 2018-02-06 14:01:25 +0000 | [diff] [blame] | 254 | static int orangefs_inode_is_stale(struct inode *inode, |
Martin Brandenburg | 2666263 | 2016-03-17 16:01:52 -0400 | [diff] [blame] | 255 | struct ORANGEFS_sys_attr_s *attrs, char *link_target) |
| 256 | { |
| 257 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
| 258 | int type = orangefs_inode_type(attrs->objtype); |
Martin Brandenburg | 480e5ae | 2018-02-06 14:01:25 +0000 | [diff] [blame] | 259 | /* |
| 260 | * If the inode type or symlink target have changed then this |
| 261 | * inode is stale. |
| 262 | */ |
| 263 | if (type == -1 || !(inode->i_mode & type)) { |
| 264 | orangefs_make_bad_inode(inode); |
| 265 | return 1; |
| 266 | } |
| 267 | if (type == S_IFLNK && strncmp(orangefs_inode->link_target, |
| 268 | link_target, ORANGEFS_NAME_MAX)) { |
| 269 | orangefs_make_bad_inode(inode); |
| 270 | return 1; |
Martin Brandenburg | 2666263 | 2016-03-17 16:01:52 -0400 | [diff] [blame] | 271 | } |
| 272 | return 0; |
| 273 | } |
| 274 | |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 275 | int orangefs_inode_getattr(struct inode *inode, int new, int bypass, |
| 276 | u32 request_mask) |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 277 | { |
| 278 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
| 279 | struct orangefs_kernel_op_s *new_op; |
Martin Brandenburg | 9f8fd53 | 2018-05-31 16:36:59 +0000 | [diff] [blame] | 280 | loff_t inode_size; |
Martin Brandenburg | 2666263 | 2016-03-17 16:01:52 -0400 | [diff] [blame] | 281 | int ret, type; |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 282 | |
| 283 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: called on inode %pU\n", __func__, |
| 284 | get_khandle_from_ino(inode)); |
| 285 | |
Martin Brandenburg | 71680c1 | 2016-06-09 16:32:38 -0400 | [diff] [blame] | 286 | if (!new && !bypass) { |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 287 | /* |
| 288 | * Must have all the attributes in the mask and be within cache |
| 289 | * time. |
| 290 | */ |
| 291 | if ((request_mask & orangefs_inode->getattr_mask) == |
| 292 | request_mask && |
| 293 | time_before(jiffies, orangefs_inode->getattr_time)) |
Martin Brandenburg | 71680c1 | 2016-06-09 16:32:38 -0400 | [diff] [blame] | 294 | return 0; |
| 295 | } |
| 296 | |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 297 | new_op = op_alloc(ORANGEFS_VFS_OP_GETATTR); |
| 298 | if (!new_op) |
| 299 | return -ENOMEM; |
| 300 | new_op->upcall.req.getattr.refn = orangefs_inode->refn; |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 301 | /* |
| 302 | * Size is the hardest attribute to get. The incremental cost of any |
| 303 | * other attribute is essentially zero. |
| 304 | */ |
| 305 | if (request_mask & STATX_SIZE || new) |
| 306 | new_op->upcall.req.getattr.mask = ORANGEFS_ATTR_SYS_ALL_NOHINT; |
| 307 | else |
| 308 | new_op->upcall.req.getattr.mask = |
| 309 | ORANGEFS_ATTR_SYS_ALL_NOHINT & ~ORANGEFS_ATTR_SYS_SIZE; |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 310 | |
| 311 | ret = service_operation(new_op, __func__, |
| 312 | get_interruptible_flag(inode)); |
| 313 | if (ret != 0) |
| 314 | goto out; |
| 315 | |
Martin Brandenburg | 480e5ae | 2018-02-06 14:01:25 +0000 | [diff] [blame] | 316 | if (!new) { |
| 317 | ret = orangefs_inode_is_stale(inode, |
| 318 | &new_op->downcall.resp.getattr.attributes, |
| 319 | new_op->downcall.resp.getattr.link_target); |
| 320 | if (ret) { |
| 321 | ret = -ESTALE; |
| 322 | goto out; |
| 323 | } |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 324 | } |
| 325 | |
Martin Brandenburg | 480e5ae | 2018-02-06 14:01:25 +0000 | [diff] [blame] | 326 | type = orangefs_inode_type(new_op-> |
| 327 | downcall.resp.getattr.attributes.objtype); |
Martin Brandenburg | 2666263 | 2016-03-17 16:01:52 -0400 | [diff] [blame] | 328 | switch (type) { |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 329 | case S_IFREG: |
| 330 | inode->i_flags = orangefs_inode_flags(&new_op-> |
| 331 | downcall.resp.getattr.attributes); |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 332 | if (request_mask & STATX_SIZE || new) { |
| 333 | inode_size = (loff_t)new_op-> |
| 334 | downcall.resp.getattr.attributes.size; |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 335 | inode->i_size = inode_size; |
Martin Brandenburg | 9f8fd53 | 2018-05-31 16:36:59 +0000 | [diff] [blame] | 336 | inode->i_blkbits = ffs(new_op->downcall.resp.getattr. |
| 337 | attributes.blksize); |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 338 | spin_lock(&inode->i_lock); |
| 339 | inode->i_bytes = inode_size; |
| 340 | inode->i_blocks = |
Martin Brandenburg | 9f8fd53 | 2018-05-31 16:36:59 +0000 | [diff] [blame] | 341 | (inode_size + 512 - inode_size % 512)/512; |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 342 | spin_unlock(&inode->i_lock); |
| 343 | } |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 344 | break; |
| 345 | case S_IFDIR: |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 346 | if (request_mask & STATX_SIZE || new) { |
| 347 | inode->i_size = PAGE_SIZE; |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 348 | spin_lock(&inode->i_lock); |
| 349 | inode_set_bytes(inode, inode->i_size); |
| 350 | spin_unlock(&inode->i_lock); |
| 351 | } |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 352 | set_nlink(inode, 1); |
| 353 | break; |
| 354 | case S_IFLNK: |
| 355 | if (new) { |
| 356 | inode->i_size = (loff_t)strlen(new_op-> |
| 357 | downcall.resp.getattr.link_target); |
Martin Brandenburg | 2eacea7 | 2016-04-08 13:33:21 -0400 | [diff] [blame] | 358 | ret = strscpy(orangefs_inode->link_target, |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 359 | new_op->downcall.resp.getattr.link_target, |
| 360 | ORANGEFS_NAME_MAX); |
Martin Brandenburg | 2eacea7 | 2016-04-08 13:33:21 -0400 | [diff] [blame] | 361 | if (ret == -E2BIG) { |
| 362 | ret = -EIO; |
| 363 | goto out; |
| 364 | } |
Martin Brandenburg | e8da254 | 2016-03-18 14:20:15 -0400 | [diff] [blame] | 365 | inode->i_link = orangefs_inode->link_target; |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 366 | } |
| 367 | break; |
Martin Brandenburg | 480e5ae | 2018-02-06 14:01:25 +0000 | [diff] [blame] | 368 | /* i.e. -1 */ |
| 369 | default: |
| 370 | /* XXX: ESTALE? This is what is done if it is not new. */ |
| 371 | orangefs_make_bad_inode(inode); |
| 372 | ret = -ESTALE; |
| 373 | goto out; |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | inode->i_uid = make_kuid(&init_user_ns, new_op-> |
| 377 | downcall.resp.getattr.attributes.owner); |
| 378 | inode->i_gid = make_kgid(&init_user_ns, new_op-> |
| 379 | downcall.resp.getattr.attributes.group); |
| 380 | inode->i_atime.tv_sec = (time64_t)new_op-> |
| 381 | downcall.resp.getattr.attributes.atime; |
| 382 | inode->i_mtime.tv_sec = (time64_t)new_op-> |
| 383 | downcall.resp.getattr.attributes.mtime; |
| 384 | inode->i_ctime.tv_sec = (time64_t)new_op-> |
| 385 | downcall.resp.getattr.attributes.ctime; |
| 386 | inode->i_atime.tv_nsec = 0; |
| 387 | inode->i_mtime.tv_nsec = 0; |
| 388 | inode->i_ctime.tv_nsec = 0; |
| 389 | |
| 390 | /* special case: mark the root inode as sticky */ |
Martin Brandenburg | 2666263 | 2016-03-17 16:01:52 -0400 | [diff] [blame] | 391 | inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) | |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 392 | orangefs_inode_perms(&new_op->downcall.resp.getattr.attributes); |
| 393 | |
Martin Brandenburg | 1d50361 | 2016-08-16 11:38:14 -0400 | [diff] [blame] | 394 | orangefs_inode->getattr_time = jiffies + |
| 395 | orangefs_getattr_timeout_msecs*HZ/1000; |
Martin Brandenburg | 68a24a6 | 2017-04-25 15:38:03 -0400 | [diff] [blame] | 396 | if (request_mask & STATX_SIZE || new) |
| 397 | orangefs_inode->getattr_mask = STATX_BASIC_STATS; |
| 398 | else |
| 399 | orangefs_inode->getattr_mask = STATX_BASIC_STATS & ~STATX_SIZE; |
Martin Brandenburg | 3c9cf98 | 2016-03-15 11:28:20 -0400 | [diff] [blame] | 400 | ret = 0; |
| 401 | out: |
| 402 | op_release(new_op); |
| 403 | return ret; |
| 404 | } |
| 405 | |
Martin Brandenburg | 5859d77 | 2016-03-17 15:15:16 -0400 | [diff] [blame] | 406 | int orangefs_inode_check_changed(struct inode *inode) |
| 407 | { |
| 408 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
| 409 | struct orangefs_kernel_op_s *new_op; |
| 410 | int ret; |
| 411 | |
| 412 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: called on inode %pU\n", __func__, |
| 413 | get_khandle_from_ino(inode)); |
| 414 | |
| 415 | new_op = op_alloc(ORANGEFS_VFS_OP_GETATTR); |
| 416 | if (!new_op) |
| 417 | return -ENOMEM; |
| 418 | new_op->upcall.req.getattr.refn = orangefs_inode->refn; |
| 419 | new_op->upcall.req.getattr.mask = ORANGEFS_ATTR_SYS_TYPE | |
| 420 | ORANGEFS_ATTR_SYS_LNK_TARGET; |
| 421 | |
| 422 | ret = service_operation(new_op, __func__, |
| 423 | get_interruptible_flag(inode)); |
| 424 | if (ret != 0) |
| 425 | goto out; |
| 426 | |
Martin Brandenburg | 480e5ae | 2018-02-06 14:01:25 +0000 | [diff] [blame] | 427 | ret = orangefs_inode_is_stale(inode, |
Martin Brandenburg | 2666263 | 2016-03-17 16:01:52 -0400 | [diff] [blame] | 428 | &new_op->downcall.resp.getattr.attributes, |
| 429 | new_op->downcall.resp.getattr.link_target); |
Martin Brandenburg | 5859d77 | 2016-03-17 15:15:16 -0400 | [diff] [blame] | 430 | out: |
| 431 | op_release(new_op); |
| 432 | return ret; |
| 433 | } |
| 434 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 435 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 436 | * issues a orangefs setattr request to make sure the new attribute values |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 437 | * take effect if successful. returns 0 on success; -errno otherwise |
| 438 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 439 | int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 440 | { |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 441 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
| 442 | struct orangefs_kernel_op_s *new_op; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 443 | int ret; |
| 444 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 445 | new_op = op_alloc(ORANGEFS_VFS_OP_SETATTR); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 446 | if (!new_op) |
| 447 | return -ENOMEM; |
| 448 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 449 | new_op->upcall.req.setattr.refn = orangefs_inode->refn; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 450 | ret = copy_attributes_from_inode(inode, |
| 451 | &new_op->upcall.req.setattr.attributes, |
| 452 | iattr); |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 453 | if (ret >= 0) { |
| 454 | ret = service_operation(new_op, __func__, |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 455 | get_interruptible_flag(inode)); |
| 456 | |
Al Viro | ed42fe0 | 2016-01-22 19:47:47 -0500 | [diff] [blame] | 457 | gossip_debug(GOSSIP_UTILS_DEBUG, |
| 458 | "orangefs_inode_setattr: returning %d\n", |
| 459 | ret); |
| 460 | } |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 461 | |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 462 | op_release(new_op); |
| 463 | |
Martin Brandenburg | a55f2d8 | 2017-11-07 15:01:40 -0500 | [diff] [blame] | 464 | if (ret == 0) |
Martin Brandenburg | 8bbb20a | 2016-07-28 14:46:36 -0400 | [diff] [blame] | 465 | orangefs_inode->getattr_time = jiffies - 1; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 466 | |
| 467 | return ret; |
| 468 | } |
| 469 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 470 | /* |
| 471 | * The following is a very dirty hack that is now a permanent part of the |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 472 | * ORANGEFS protocol. See protocol.h for more error definitions. |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 473 | */ |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 474 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 475 | /* The order matches include/orangefs-types.h in the OrangeFS source. */ |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 476 | static int PINT_errno_mapping[] = { |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 477 | 0, EPERM, ENOENT, EINTR, EIO, ENXIO, EBADF, EAGAIN, ENOMEM, |
| 478 | EFAULT, EBUSY, EEXIST, ENODEV, ENOTDIR, EISDIR, EINVAL, EMFILE, |
| 479 | EFBIG, ENOSPC, EROFS, EMLINK, EPIPE, EDEADLK, ENAMETOOLONG, |
| 480 | ENOLCK, ENOSYS, ENOTEMPTY, ELOOP, EWOULDBLOCK, ENOMSG, EUNATCH, |
| 481 | EBADR, EDEADLOCK, ENODATA, ETIME, ENONET, EREMOTE, ECOMM, |
| 482 | EPROTO, EBADMSG, EOVERFLOW, ERESTART, EMSGSIZE, EPROTOTYPE, |
| 483 | ENOPROTOOPT, EPROTONOSUPPORT, EOPNOTSUPP, EADDRINUSE, |
| 484 | EADDRNOTAVAIL, ENETDOWN, ENETUNREACH, ENETRESET, ENOBUFS, |
| 485 | ETIMEDOUT, ECONNREFUSED, EHOSTDOWN, EHOSTUNREACH, EALREADY, |
| 486 | EACCES, ECONNRESET, ERANGE |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 487 | }; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 488 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 489 | int orangefs_normalize_to_errno(__s32 error_code) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 490 | { |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 491 | __u32 i; |
| 492 | |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 493 | /* Success */ |
| 494 | if (error_code == 0) { |
| 495 | return 0; |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 496 | /* |
| 497 | * This shouldn't ever happen. If it does it should be fixed on the |
| 498 | * server. |
| 499 | */ |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 500 | } else if (error_code > 0) { |
Masanari Iida | bc8282a | 2018-01-16 00:18:36 +0900 | [diff] [blame] | 501 | gossip_err("orangefs: error status received.\n"); |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 502 | gossip_err("orangefs: assuming error code is inverted.\n"); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 503 | error_code = -error_code; |
| 504 | } |
| 505 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 506 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 507 | * XXX: This is very bad since error codes from ORANGEFS may not be |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 508 | * suitable for return into userspace. |
| 509 | */ |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 510 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 511 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 512 | * Convert ORANGEFS error values into errno values suitable for return |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 513 | * from the kernel. |
| 514 | */ |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 515 | if ((-error_code) & ORANGEFS_NON_ERRNO_ERROR_BIT) { |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 516 | if (((-error_code) & |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 517 | (ORANGEFS_ERROR_NUMBER_BITS|ORANGEFS_NON_ERRNO_ERROR_BIT| |
| 518 | ORANGEFS_ERROR_BIT)) == ORANGEFS_ECANCEL) { |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 519 | /* |
| 520 | * cancellation error codes generally correspond to |
| 521 | * a timeout from the client's perspective |
| 522 | */ |
| 523 | error_code = -ETIMEDOUT; |
| 524 | } else { |
| 525 | /* assume a default error code */ |
Mike Marshall | 95f5f88 | 2018-05-11 17:11:48 -0400 | [diff] [blame] | 526 | gossip_err("%s: bad error code :%d:.\n", |
| 527 | __func__, |
| 528 | error_code); |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 529 | error_code = -EINVAL; |
| 530 | } |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 531 | |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 532 | /* Convert ORANGEFS encoded errno values into regular errno values. */ |
| 533 | } else if ((-error_code) & ORANGEFS_ERROR_BIT) { |
| 534 | i = (-error_code) & ~(ORANGEFS_ERROR_BIT|ORANGEFS_ERROR_CLASS_BITS); |
Jérémy Lefaure | 296200d | 2017-10-01 15:30:48 -0400 | [diff] [blame] | 535 | if (i < ARRAY_SIZE(PINT_errno_mapping)) |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 536 | error_code = -PINT_errno_mapping[i]; |
| 537 | else |
| 538 | error_code = -EINVAL; |
| 539 | |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 540 | /* |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 541 | * Only ORANGEFS protocol error codes should ever come here. Otherwise |
Mike Marshall | 5480494 | 2015-10-05 13:44:24 -0400 | [diff] [blame] | 542 | * there is a bug somewhere. |
| 543 | */ |
Martin Brandenburg | 894ac43 | 2015-10-02 12:11:19 -0400 | [diff] [blame] | 544 | } else { |
Mike Marshall | 95f5f88 | 2018-05-11 17:11:48 -0400 | [diff] [blame] | 545 | gossip_err("%s: unknown error code.\n", __func__); |
Mike Marshall | cf546ab | 2018-01-25 14:43:28 -0500 | [diff] [blame] | 546 | error_code = -EINVAL; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 547 | } |
| 548 | return error_code; |
| 549 | } |
| 550 | |
| 551 | #define NUM_MODES 11 |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 552 | __s32 ORANGEFS_util_translate_mode(int mode) |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 553 | { |
| 554 | int ret = 0; |
| 555 | int i = 0; |
| 556 | static int modes[NUM_MODES] = { |
| 557 | S_IXOTH, S_IWOTH, S_IROTH, |
| 558 | S_IXGRP, S_IWGRP, S_IRGRP, |
| 559 | S_IXUSR, S_IWUSR, S_IRUSR, |
| 560 | S_ISGID, S_ISUID |
| 561 | }; |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 562 | static int orangefs_modes[NUM_MODES] = { |
| 563 | ORANGEFS_O_EXECUTE, ORANGEFS_O_WRITE, ORANGEFS_O_READ, |
| 564 | ORANGEFS_G_EXECUTE, ORANGEFS_G_WRITE, ORANGEFS_G_READ, |
| 565 | ORANGEFS_U_EXECUTE, ORANGEFS_U_WRITE, ORANGEFS_U_READ, |
| 566 | ORANGEFS_G_SGID, ORANGEFS_U_SUID |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 567 | }; |
| 568 | |
| 569 | for (i = 0; i < NUM_MODES; i++) |
| 570 | if (mode & modes[i]) |
Yi Liu | 8bb8aef | 2015-11-24 15:12:14 -0500 | [diff] [blame] | 571 | ret |= orangefs_modes[i]; |
Mike Marshall | f7be4ee | 2015-07-17 10:38:14 -0400 | [diff] [blame] | 572 | |
| 573 | return ret; |
| 574 | } |
| 575 | #undef NUM_MODES |