Changeset 745 for trunk/server/source3/modules/vfs_gpfs.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/modules/vfs_gpfs.c
r599 r745 23 23 24 24 #include "includes.h" 25 #include "smbd/smbd.h" 26 #include "librpc/gen_ndr/ndr_xattr.h" 27 #include "include/smbprofile.h" 25 28 26 29 #undef DBGC_CLASS … … 30 33 #include "nfs4_acls.h" 31 34 #include "vfs_gpfs.h" 35 #include "system/filesys.h" 32 36 33 37 struct gpfs_config_data { 34 38 bool sharemodes; 35 39 bool leases; 40 bool hsm; 36 41 }; 37 42 … … 117 122 char real_pathname[PATH_MAX+1]; 118 123 int buflen; 124 bool mangled; 125 126 mangled = mangle_is_mangled(name, handle->conn->params); 127 if (mangled) { 128 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, 129 mem_ctx, found_name); 130 } 119 131 120 132 full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name); … … 323 335 static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle, 324 336 files_struct *fsp, uint32 security_info, 325 SEC_DESC**ppdesc)337 struct security_descriptor **ppdesc) 326 338 { 327 339 SMB4ACL_T *pacl = NULL; … … 345 357 static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle, 346 358 const char *name, 347 uint32 security_info, SEC_DESC**ppdesc)359 uint32 security_info, struct security_descriptor **ppdesc) 348 360 { 349 361 SMB4ACL_T *pacl = NULL; … … 461 473 } 462 474 463 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const SEC_DESC*psd)475 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) 464 476 { 465 477 struct gpfs_acl *acl; … … 489 501 } 490 502 491 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC*psd)503 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) 492 504 { 493 505 return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd); … … 927 939 static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path, 928 940 const char *name, const void *value, size_t size, int flags){ 941 struct xattr_DOSATTRIB dosattrib; 942 enum ndr_err_code ndr_err; 943 DATA_BLOB blob; 929 944 const char *attrstr = value; 930 945 unsigned int dosmode=0; … … 940 955 } 941 956 942 if (size < 2 || attrstr[0] != '0' || attrstr[1] != 'x' || 943 sscanf(attrstr, "%x", &dosmode) != 1) { 944 DEBUG(1,("gpfs_set_xattr: Trying to set badly formed DOSATTRIB on file %s - %s\n", path, attrstr)); 945 return False; 946 } 957 blob.data = (uint8_t *)attrstr; 958 blob.length = size; 959 960 ndr_err = ndr_pull_struct_blob(&blob, talloc_tos(), &dosattrib, 961 (ndr_pull_flags_fn_t)ndr_pull_xattr_DOSATTRIB); 962 963 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 964 DEBUG(1, ("gpfs_set_xattr: bad ndr decode " 965 "from EA on file %s: Error = %s\n", 966 path, ndr_errstr(ndr_err))); 967 return false; 968 } 969 970 if (dosattrib.version != 3) { 971 DEBUG(1, ("gpfs_set_xattr: expected dosattrib version 3, got " 972 "%d\n", (int)dosattrib.version)); 973 return false; 974 } 975 if (!(dosattrib.info.info3.valid_flags & XATTR_DOSINFO_ATTRIB)) { 976 DEBUG(10, ("gpfs_set_xattr: XATTR_DOSINFO_ATTRIB not " 977 "valid, ignoring\n")); 978 return true; 979 } 980 981 dosmode = dosattrib.info.info3.attrib; 947 982 948 983 attrs.winAttrs = 0; 949 /*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/984 /*Just map RD_ONLY, ARCHIVE, SYSTEM HIDDEN and SPARSE. Ignore the others*/ 950 985 if (dosmode & FILE_ATTRIBUTE_ARCHIVE){ 951 986 attrs.winAttrs |= GPFS_WINATTR_ARCHIVE; … … 960 995 attrs.winAttrs |= GPFS_WINATTR_READONLY; 961 996 } 997 if (dosmode & FILE_ATTRIBUTE_SPARSE) { 998 attrs.winAttrs |= GPFS_WINATTR_SPARSE_FILE; 999 } 962 1000 963 1001 … … 984 1022 struct gpfs_winattr attrs; 985 1023 int ret = 0; 986 ssize_t result;987 1024 988 1025 DEBUG(10, ("gpfs_get_xattr: %s \n",path)); … … 1001 1038 } 1002 1039 1003 DEBUG(1, ("gpfs_get_xattr: Get GPFS attributes failed: %d\n",ret)); 1040 DEBUG(1, ("gpfs_get_xattr: Get GPFS attributes failed: " 1041 "%d (%s)\n", ret, strerror(errno))); 1004 1042 return -1; 1005 1043 } … … 1007 1045 DEBUG(10, ("gpfs_get_xattr:Got attributes: 0x%x\n",attrs.winAttrs)); 1008 1046 1009 /*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/1047 /*Just map RD_ONLY, ARCHIVE, SYSTEM, HIDDEN and SPARSE. Ignore the others*/ 1010 1048 if (attrs.winAttrs & GPFS_WINATTR_ARCHIVE){ 1011 1049 dosmode |= FILE_ATTRIBUTE_ARCHIVE; … … 1020 1058 dosmode |= FILE_ATTRIBUTE_READONLY; 1021 1059 } 1022 1023 result = snprintf(attrstr, size, "0x%x", 1024 dosmode & SAMBA_ATTRIBUTES_MASK) + 1; 1025 1060 if (attrs.winAttrs & GPFS_WINATTR_SPARSE_FILE) { 1061 dosmode |= FILE_ATTRIBUTE_SPARSE; 1062 } 1063 1064 snprintf(attrstr, size, "0x%2.2x", 1065 (unsigned int)(dosmode & SAMBA_ATTRIBUTES_MASK)); 1026 1066 DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr)); 1027 return result;1067 return 4; 1028 1068 } 1029 1069 … … 1050 1090 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec; 1051 1091 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec; 1092 smb_fname->st.vfs_private = attrs.winAttrs; 1052 1093 } 1053 1094 return 0; … … 1097 1138 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec; 1098 1139 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec; 1140 smb_fname->st.vfs_private = attrs.winAttrs; 1099 1141 } 1100 1142 return 0; … … 1142 1184 } 1143 1185 1186 static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp, 1187 SMB_OFF_T len) 1188 { 1189 int result; 1190 1191 result = smbd_gpfs_ftruncate(fsp->fh->fd, len); 1192 if ((result == -1) && (errno == ENOSYS)) { 1193 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len); 1194 } 1195 return result; 1196 } 1197 1198 static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle, 1199 const struct smb_filename *fname, 1200 SMB_STRUCT_STAT *sbuf) 1201 { 1202 struct gpfs_winattr attrs; 1203 char *path = NULL; 1204 NTSTATUS status; 1205 1206 status = get_full_smb_filename(talloc_tos(), fname, &path); 1207 if (!NT_STATUS_IS_OK(status)) { 1208 errno = map_errno_from_nt_status(status); 1209 return -1; 1210 } 1211 1212 if (VALID_STAT(*sbuf)) { 1213 attrs.winAttrs = sbuf->vfs_private; 1214 } else { 1215 int ret; 1216 ret = get_gpfs_winattrs(path, &attrs); 1217 1218 if (ret == -1) { 1219 TALLOC_FREE(path); 1220 return false; 1221 } 1222 } 1223 if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) { 1224 DEBUG(10, ("%s is offline\n", path)); 1225 TALLOC_FREE(path); 1226 return true; 1227 } 1228 DEBUG(10, ("%s is online\n", path)); 1229 TALLOC_FREE(path); 1230 return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf); 1231 } 1232 1233 static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle, 1234 struct files_struct *fsp) 1235 { 1236 return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st); 1237 } 1238 1239 static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd, 1240 files_struct *fsp, const DATA_BLOB *hdr, 1241 SMB_OFF_T offset, size_t n) 1242 { 1243 if ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0) { 1244 errno = ENOSYS; 1245 return -1; 1246 } 1247 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n); 1248 } 1249 1144 1250 int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service, 1145 1251 const char *user) 1146 1252 { 1147 1253 struct gpfs_config_data *config; 1254 1255 smbd_gpfs_lib_init(); 1256 1148 1257 int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); 1149 1258 … … 1164 1273 "leases", true); 1165 1274 1275 config->hsm = lp_parm_bool(SNUM(handle->conn), "gpfs", 1276 "hsm", false); 1277 1166 1278 SMB_VFS_HANDLE_SET_DATA(handle, config, 1167 1279 NULL, struct gpfs_config_data, … … 1171 1283 } 1172 1284 1173 1174 static int vfs_gpfs_ftruncate(struct vfs_handle_struct *handle, 1175 struct files_struct *fsp, 1176 SMB_OFF_T len) 1177 { 1178 int result; 1179 1180 result = smbd_gpfs_ftrunctate(fsp->fh->fd, len); 1181 if ((result == -1) && (errno == ENOSYS)) { 1182 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len); 1183 } 1184 return result; 1185 } 1285 static uint32_t vfs_gpfs_capabilities(struct vfs_handle_struct *handle, 1286 enum timestamp_set_resolution *p_ts_res) 1287 { 1288 struct gpfs_config_data *config; 1289 uint32_t next; 1290 1291 next = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res); 1292 1293 SMB_VFS_HANDLE_GET_DATA(handle, config, 1294 struct gpfs_config_data, 1295 return next); 1296 1297 if (config->hsm) { 1298 next |= FILE_SUPPORTS_REMOTE_STORAGE; 1299 } 1300 return next; 1301 } 1302 1303 static int vfs_gpfs_open(struct vfs_handle_struct *handle, 1304 struct smb_filename *smb_fname, files_struct *fsp, 1305 int flags, mode_t mode) 1306 { 1307 if (lp_parm_bool(fsp->conn->params->service, "gpfs", "syncio", 1308 false)) { 1309 flags |= O_SYNC; 1310 } 1311 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); 1312 } 1313 1186 1314 1187 1315 static struct vfs_fn_pointers vfs_gpfs_fns = { 1188 1316 .connect_fn = vfs_gpfs_connect, 1317 .fs_capabilities = vfs_gpfs_capabilities, 1189 1318 .kernel_flock = vfs_gpfs_kernel_flock, 1190 1319 .linux_setlease = vfs_gpfs_setlease, … … 1207 1336 .lstat = vfs_gpfs_lstat, 1208 1337 .ntimes = vfs_gpfs_ntimes, 1209 .ftruncate = vfs_gpfs_ftruncate, 1338 .is_offline = vfs_gpfs_is_offline, 1339 .aio_force = vfs_gpfs_aio_force, 1340 .sendfile = vfs_gpfs_sendfile, 1341 .open_fn = vfs_gpfs_open, 1342 .ftruncate = vfs_gpfs_ftruncate 1210 1343 }; 1211 1344
Note:
See TracChangeset
for help on using the changeset viewer.