]> Pileus Git - ~andy/linux/blobdiff - fs/cifs/inode.c
Merge tag 'sunxi-fixes-for-3.14' of https://github.com/mripard/linux into fixes
[~andy/linux] / fs / cifs / inode.c
index 49719b8228e58bd44b373fd4b39d844be9e2043b..be58b8fcdb3c321ffbab033a4a91abc76c774df3 100644 (file)
@@ -383,10 +383,10 @@ int cifs_get_inode_info_unix(struct inode **pinode,
 
        /* check for Minshall+French symlinks */
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) {
-               int tmprc = CIFSCheckMFSymlink(xid, tcon, cifs_sb, &fattr,
-                                              full_path);
+               int tmprc = check_mf_symlink(xid, tcon, cifs_sb, &fattr,
+                                            full_path);
                if (tmprc)
-                       cifs_dbg(FYI, "CIFSCheckMFSymlink: %d\n", tmprc);
+                       cifs_dbg(FYI, "check_mf_symlink: %d\n", tmprc);
        }
 
        if (*pinode == NULL) {
@@ -404,18 +404,20 @@ int cifs_get_inode_info_unix(struct inode **pinode,
 }
 
 static int
-cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path,
+cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
              struct cifs_sb_info *cifs_sb, unsigned int xid)
 {
        int rc;
        int oplock = 0;
-       __u16 netfid;
        struct tcon_link *tlink;
        struct cifs_tcon *tcon;
+       struct cifs_fid fid;
+       struct cifs_open_parms oparms;
        struct cifs_io_parms io_parms;
        char buf[24];
        unsigned int bytes_read;
        char *pbuf;
+       int buf_type = CIFS_NO_BUFFER;
 
        pbuf = buf;
 
@@ -436,62 +438,69 @@ cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path,
                return PTR_ERR(tlink);
        tcon = tlink_tcon(tlink);
 
-       rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ,
-                        CREATE_NOT_DIR, &netfid, &oplock, NULL,
-                        cifs_sb->local_nls,
-                        cifs_sb->mnt_cifs_flags &
-                               CIFS_MOUNT_MAP_SPECIAL_CHR);
-       if (rc == 0) {
-               int buf_type = CIFS_NO_BUFFER;
-                       /* Read header */
-               io_parms.netfid = netfid;
-               io_parms.pid = current->tgid;
-               io_parms.tcon = tcon;
-               io_parms.offset = 0;
-               io_parms.length = 24;
-               rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf,
-                                &buf_type);
-               if ((rc == 0) && (bytes_read >= 8)) {
-                       if (memcmp("IntxBLK", pbuf, 8) == 0) {
-                               cifs_dbg(FYI, "Block device\n");
-                               fattr->cf_mode |= S_IFBLK;
-                               fattr->cf_dtype = DT_BLK;
-                               if (bytes_read == 24) {
-                                       /* we have enough to decode dev num */
-                                       __u64 mjr; /* major */
-                                       __u64 mnr; /* minor */
-                                       mjr = le64_to_cpu(*(__le64 *)(pbuf+8));
-                                       mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
-                                       fattr->cf_rdev = MKDEV(mjr, mnr);
-                               }
-                       } else if (memcmp("IntxCHR", pbuf, 8) == 0) {
-                               cifs_dbg(FYI, "Char device\n");
-                               fattr->cf_mode |= S_IFCHR;
-                               fattr->cf_dtype = DT_CHR;
-                               if (bytes_read == 24) {
-                                       /* we have enough to decode dev num */
-                                       __u64 mjr; /* major */
-                                       __u64 mnr; /* minor */
-                                       mjr = le64_to_cpu(*(__le64 *)(pbuf+8));
-                                       mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
-                                       fattr->cf_rdev = MKDEV(mjr, mnr);
-                               }
-                       } else if (memcmp("IntxLNK", pbuf, 7) == 0) {
-                               cifs_dbg(FYI, "Symlink\n");
-                               fattr->cf_mode |= S_IFLNK;
-                               fattr->cf_dtype = DT_LNK;
-                       } else {
-                               fattr->cf_mode |= S_IFREG; /* file? */
-                               fattr->cf_dtype = DT_REG;
-                               rc = -EOPNOTSUPP;
+       oparms.tcon = tcon;
+       oparms.cifs_sb = cifs_sb;
+       oparms.desired_access = GENERIC_READ;
+       oparms.create_options = CREATE_NOT_DIR;
+       oparms.disposition = FILE_OPEN;
+       oparms.path = path;
+       oparms.fid = &fid;
+       oparms.reconnect = false;
+
+       rc = CIFS_open(xid, &oparms, &oplock, NULL);
+       if (rc) {
+               cifs_put_tlink(tlink);
+               return rc;
+       }
+
+       /* Read header */
+       io_parms.netfid = fid.netfid;
+       io_parms.pid = current->tgid;
+       io_parms.tcon = tcon;
+       io_parms.offset = 0;
+       io_parms.length = 24;
+
+       rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type);
+       if ((rc == 0) && (bytes_read >= 8)) {
+               if (memcmp("IntxBLK", pbuf, 8) == 0) {
+                       cifs_dbg(FYI, "Block device\n");
+                       fattr->cf_mode |= S_IFBLK;
+                       fattr->cf_dtype = DT_BLK;
+                       if (bytes_read == 24) {
+                               /* we have enough to decode dev num */
+                               __u64 mjr; /* major */
+                               __u64 mnr; /* minor */
+                               mjr = le64_to_cpu(*(__le64 *)(pbuf+8));
+                               mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
+                               fattr->cf_rdev = MKDEV(mjr, mnr);
                        }
+               } else if (memcmp("IntxCHR", pbuf, 8) == 0) {
+                       cifs_dbg(FYI, "Char device\n");
+                       fattr->cf_mode |= S_IFCHR;
+                       fattr->cf_dtype = DT_CHR;
+                       if (bytes_read == 24) {
+                               /* we have enough to decode dev num */
+                               __u64 mjr; /* major */
+                               __u64 mnr; /* minor */
+                               mjr = le64_to_cpu(*(__le64 *)(pbuf+8));
+                               mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
+                               fattr->cf_rdev = MKDEV(mjr, mnr);
+                       }
+               } else if (memcmp("IntxLNK", pbuf, 7) == 0) {
+                       cifs_dbg(FYI, "Symlink\n");
+                       fattr->cf_mode |= S_IFLNK;
+                       fattr->cf_dtype = DT_LNK;
                } else {
-                       fattr->cf_mode |= S_IFREG; /* then it is a file */
+                       fattr->cf_mode |= S_IFREG; /* file? */
                        fattr->cf_dtype = DT_REG;
-                       rc = -EOPNOTSUPP; /* or some unknown SFU type */
+                       rc = -EOPNOTSUPP;
                }
-               CIFSSMBClose(xid, tcon, netfid);
+       } else {
+               fattr->cf_mode |= S_IFREG; /* then it is a file */
+               fattr->cf_dtype = DT_REG;
+               rc = -EOPNOTSUPP; /* or some unknown SFU type */
        }
+       CIFSSMBClose(xid, tcon, fid.netfid);
        cifs_put_tlink(tlink);
        return rc;
 }
@@ -518,10 +527,15 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path,
                return PTR_ERR(tlink);
        tcon = tlink_tcon(tlink);
 
-       rc = CIFSSMBQAllEAs(xid, tcon, path, "SETFILEBITS",
-                           ea_value, 4 /* size of buf */, cifs_sb->local_nls,
-                           cifs_sb->mnt_cifs_flags &
-                               CIFS_MOUNT_MAP_SPECIAL_CHR);
+       if (tcon->ses->server->ops->query_all_EAs == NULL) {
+               cifs_put_tlink(tlink);
+               return -EOPNOTSUPP;
+       }
+
+       rc = tcon->ses->server->ops->query_all_EAs(xid, tcon, path,
+                       "SETFILEBITS", ea_value, 4 /* size of buf */,
+                       cifs_sb->local_nls,
+                       cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
        cifs_put_tlink(tlink);
        if (rc < 0)
                return (int)rc;
@@ -800,10 +814,10 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
 
        /* check for Minshall+French symlinks */
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) {
-               tmprc = CIFSCheckMFSymlink(xid, tcon, cifs_sb, &fattr,
-                                          full_path);
+               tmprc = check_mf_symlink(xid, tcon, cifs_sb, &fattr,
+                                        full_path);
                if (tmprc)
-                       cifs_dbg(FYI, "CIFSCheckMFSymlink: %d\n", tmprc);
+                       cifs_dbg(FYI, "check_mf_symlink: %d\n", tmprc);
        }
 
        if (!*inode) {
@@ -1032,7 +1046,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
 {
        int oplock = 0;
        int rc;
-       __u16 netfid;
+       struct cifs_fid fid;
+       struct cifs_open_parms oparms;
        struct inode *inode = dentry->d_inode;
        struct cifsInodeInfo *cifsInode = CIFS_I(inode);
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
@@ -1055,10 +1070,16 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
                goto out;
        }
 
-       rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN,
-                        DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR,
-                        &netfid, &oplock, NULL, cifs_sb->local_nls,
-                        cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
+       oparms.tcon = tcon;
+       oparms.cifs_sb = cifs_sb;
+       oparms.desired_access = DELETE | FILE_WRITE_ATTRIBUTES;
+       oparms.create_options = CREATE_NOT_DIR;
+       oparms.disposition = FILE_OPEN;
+       oparms.path = full_path;
+       oparms.fid = &fid;
+       oparms.reconnect = false;
+
+       rc = CIFS_open(xid, &oparms, &oplock, NULL);
        if (rc != 0)
                goto out;
 
@@ -1079,7 +1100,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
                        goto out_close;
                }
                info_buf->Attributes = cpu_to_le32(dosattr);
-               rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid,
+               rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid,
                                        current->tgid);
                /* although we would like to mark the file hidden
                   if that fails we will still try to rename it */
@@ -1090,7 +1111,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
        }
 
        /* rename the file */
-       rc = CIFSSMBRenameOpenFile(xid, tcon, netfid, NULL, cifs_sb->local_nls,
+       rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, NULL,
+                                  cifs_sb->local_nls,
                                   cifs_sb->mnt_cifs_flags &
                                            CIFS_MOUNT_MAP_SPECIAL_CHR);
        if (rc != 0) {
@@ -1100,7 +1122,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
 
        /* try to set DELETE_ON_CLOSE */
        if (!cifsInode->delete_pending) {
-               rc = CIFSSMBSetFileDisposition(xid, tcon, true, netfid,
+               rc = CIFSSMBSetFileDisposition(xid, tcon, true, fid.netfid,
                                               current->tgid);
                /*
                 * some samba versions return -ENOENT when we try to set the
@@ -1120,7 +1142,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
        }
 
 out_close:
-       CIFSSMBClose(xid, tcon, netfid);
+       CIFSSMBClose(xid, tcon, fid.netfid);
 out:
        kfree(info_buf);
        cifs_put_tlink(tlink);
@@ -1132,13 +1154,13 @@ out:
         * them anyway.
         */
 undo_rename:
-       CIFSSMBRenameOpenFile(xid, tcon, netfid, dentry->d_name.name,
+       CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, dentry->d_name.name,
                                cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                                            CIFS_MOUNT_MAP_SPECIAL_CHR);
 undo_setattr:
        if (dosattr != origattr) {
                info_buf->Attributes = cpu_to_le32(origattr);
-               if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid,
+               if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid,
                                        current->tgid))
                        cifsInode->cifsAttrs = origattr;
        }
@@ -1549,7 +1571,8 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
        struct tcon_link *tlink;
        struct cifs_tcon *tcon;
        struct TCP_Server_Info *server;
-       __u16 srcfid;
+       struct cifs_fid fid;
+       struct cifs_open_parms oparms;
        int oplock, rc;
 
        tlink = cifs_sb_tlink(cifs_sb);
@@ -1576,17 +1599,23 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
        if (to_dentry->d_parent != from_dentry->d_parent)
                goto do_rename_exit;
 
+       oparms.tcon = tcon;
+       oparms.cifs_sb = cifs_sb;
        /* open the file to be renamed -- we need DELETE perms */
-       rc = CIFSSMBOpen(xid, tcon, from_path, FILE_OPEN, DELETE,
-                        CREATE_NOT_DIR, &srcfid, &oplock, NULL,
-                        cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
-                               CIFS_MOUNT_MAP_SPECIAL_CHR);
+       oparms.desired_access = DELETE;
+       oparms.create_options = CREATE_NOT_DIR;
+       oparms.disposition = FILE_OPEN;
+       oparms.path = from_path;
+       oparms.fid = &fid;
+       oparms.reconnect = false;
+
+       rc = CIFS_open(xid, &oparms, &oplock, NULL);
        if (rc == 0) {
-               rc = CIFSSMBRenameOpenFile(xid, tcon, srcfid,
+               rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid,
                                (const char *) to_dentry->d_name.name,
                                cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
                                        CIFS_MOUNT_MAP_SPECIAL_CHR);
-               CIFSSMBClose(xid, tcon, srcfid);
+               CIFSSMBClose(xid, tcon, fid.netfid);
        }
 do_rename_exit:
        cifs_put_tlink(tlink);