Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/modules/vfs_gpfs.c

    r599 r745  
    2323
    2424#include "includes.h"
     25#include "smbd/smbd.h"
     26#include "librpc/gen_ndr/ndr_xattr.h"
     27#include "include/smbprofile.h"
    2528
    2629#undef DBGC_CLASS
     
    3033#include "nfs4_acls.h"
    3134#include "vfs_gpfs.h"
     35#include "system/filesys.h"
    3236
    3337struct gpfs_config_data {
    3438        bool sharemodes;
    3539        bool leases;
     40        bool hsm;
    3641};
    3742
     
    117122        char real_pathname[PATH_MAX+1];
    118123        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        }
    119131
    120132        full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name);
     
    323335static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
    324336        files_struct *fsp, uint32 security_info,
    325         SEC_DESC **ppdesc)
     337        struct security_descriptor **ppdesc)
    326338{
    327339        SMB4ACL_T *pacl = NULL;
     
    345357static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
    346358        const char *name,
    347         uint32 security_info, SEC_DESC **ppdesc)
     359        uint32 security_info, struct security_descriptor **ppdesc)
    348360{
    349361        SMB4ACL_T *pacl = NULL;
     
    461473}
    462474
    463 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd)
     475static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
    464476{
    465477        struct gpfs_acl *acl;
     
    489501}
    490502
    491 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const SEC_DESC *psd)
     503static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
    492504{
    493505        return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd);
     
    927939static int gpfs_set_xattr(struct vfs_handle_struct *handle,  const char *path,
    928940                           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;
    929944        const char *attrstr = value;
    930945        unsigned int dosmode=0;
     
    940955        }
    941956
    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;
    947982
    948983        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*/
    950985        if (dosmode & FILE_ATTRIBUTE_ARCHIVE){
    951986                attrs.winAttrs |= GPFS_WINATTR_ARCHIVE;
     
    960995                        attrs.winAttrs |= GPFS_WINATTR_READONLY;
    961996        }
     997        if (dosmode & FILE_ATTRIBUTE_SPARSE) {
     998                attrs.winAttrs |= GPFS_WINATTR_SPARSE_FILE;
     999        }
    9621000
    9631001
     
    9841022        struct gpfs_winattr attrs;
    9851023        int ret = 0;
    986         ssize_t result;
    9871024
    9881025        DEBUG(10, ("gpfs_get_xattr: %s \n",path));
     
    10011038                }
    10021039
    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)));
    10041042                return -1;
    10051043        }
     
    10071045        DEBUG(10, ("gpfs_get_xattr:Got attributes: 0x%x\n",attrs.winAttrs));
    10081046
    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*/
    10101048        if (attrs.winAttrs & GPFS_WINATTR_ARCHIVE){
    10111049                dosmode |= FILE_ATTRIBUTE_ARCHIVE;
     
    10201058                dosmode |= FILE_ATTRIBUTE_READONLY;
    10211059        }
    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));
    10261066        DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr));
    1027         return result;
     1067        return 4;
    10281068}
    10291069
     
    10501090                smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
    10511091                smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
     1092                smb_fname->st.vfs_private = attrs.winAttrs;
    10521093        }
    10531094        return 0;
     
    10971138                smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
    10981139                smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
     1140                smb_fname->st.vfs_private = attrs.winAttrs;
    10991141        }
    11001142        return 0;
     
    11421184}
    11431185
     1186static 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
     1198static 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
     1233static 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
     1239static 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
    11441250int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
    11451251                        const char *user)
    11461252{
    11471253        struct gpfs_config_data *config;
     1254
     1255        smbd_gpfs_lib_init();
     1256
    11481257        int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
    11491258
     
    11641273                                        "leases", true);
    11651274
     1275        config->hsm = lp_parm_bool(SNUM(handle->conn), "gpfs",
     1276                                   "hsm", false);
     1277
    11661278        SMB_VFS_HANDLE_SET_DATA(handle, config,
    11671279                                NULL, struct gpfs_config_data,
     
    11711283}
    11721284
    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 }
     1285static 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
     1303static 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
    11861314
    11871315static struct vfs_fn_pointers vfs_gpfs_fns = {
    11881316        .connect_fn = vfs_gpfs_connect,
     1317        .fs_capabilities = vfs_gpfs_capabilities,
    11891318        .kernel_flock = vfs_gpfs_kernel_flock,
    11901319        .linux_setlease = vfs_gpfs_setlease,
     
    12071336        .lstat = vfs_gpfs_lstat,
    12081337        .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
    12101343};
    12111344
Note: See TracChangeset for help on using the changeset viewer.