]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
CIFS: Move hardlink to ops struct
authorSteve French <smfrench@gmail.com>
Tue, 18 Sep 2012 23:20:31 +0000 (16:20 -0700)
committerSteve French <smfrench@gmail.com>
Tue, 25 Sep 2012 02:46:29 +0000 (21:46 -0500)
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/cifsglob.h
fs/cifs/cifsproto.h
fs/cifs/cifssmb.c
fs/cifs/link.c
fs/cifs/smb1ops.c

index a0105c547ffd30732f303443dc6b5de0a1900208..8595d498ad80d9357308ed70955440c80ff1ec14 100644 (file)
@@ -278,6 +278,10 @@ struct smb_version_operations {
        /* send rename request */
        int (*rename)(const unsigned int, struct cifs_tcon *, const char *,
                      const char *, struct cifs_sb_info *);
+       /* send create hardlink request */
+       int (*create_hardlink)(const unsigned int, struct cifs_tcon *,
+                              const char *, const char *,
+                              struct cifs_sb_info *);
        /* open a file for non-posix mounts */
        int (*open)(const unsigned int, struct cifs_tcon *, const char *, int,
                    int, int, struct cifs_fid *, __u32 *, FILE_ALL_INFO *,
index eecd233c69128859e276b70ac3a2268cfd7b5227..3c50555c7735d5a8723b4e33f9b07ea22e3fd423 100644 (file)
@@ -316,11 +316,9 @@ extern int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *tcon,
                                 int netfid, const char *target_name,
                                 const struct nls_table *nls_codepage,
                                 int remap_special_chars);
-extern int CIFSCreateHardLink(const unsigned int xid,
-                       struct cifs_tcon *tcon,
-                       const char *fromName, const char *toName,
-                       const struct nls_table *nls_codepage,
-                       int remap_special_chars);
+extern int CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
+                             const char *from_name, const char *to_name,
+                             struct cifs_sb_info *cifs_sb);
 extern int CIFSUnixCreateHardLink(const unsigned int xid,
                        struct cifs_tcon *tcon,
                        const char *fromName, const char *toName,
index b8cd335d6f11121a6e44a38e4c815b995e63b4c4..eb3d2cf76e6e75bcf5ad32c30f15405540b43d3d 100644 (file)
@@ -2924,8 +2924,8 @@ createHardLinkRetry:
 
 int
 CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
-                  const char *fromName, const char *toName,
-                  const struct nls_table *nls_codepage, int remap)
+                  const char *from_name, const char *to_name,
+                  struct cifs_sb_info *cifs_sb)
 {
        int rc = 0;
        NT_RENAME_REQ *pSMB = NULL;
@@ -2933,6 +2933,7 @@ CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
        int bytes_returned;
        int name_len, name_len2;
        __u16 count;
+       int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
        cFYI(1, "In CIFSCreateHardLink");
 winCreateHardLinkRetry:
@@ -2952,8 +2953,8 @@ winCreateHardLinkRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUTF16((__le16 *) pSMB->OldFileName, fromName,
-                                      PATH_MAX, nls_codepage, remap);
+                   cifsConvertToUTF16((__le16 *) pSMB->OldFileName, from_name,
+                                      PATH_MAX, cifs_sb->local_nls, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
 
@@ -2962,17 +2963,18 @@ winCreateHardLinkRetry:
                pSMB->OldFileName[name_len + 1] = 0x00; /* pad */
                name_len2 =
                    cifsConvertToUTF16((__le16 *)&pSMB->OldFileName[name_len+2],
-                                      toName, PATH_MAX, nls_codepage, remap);
+                                      to_name, PATH_MAX, cifs_sb->local_nls,
+                                      remap);
                name_len2 += 1 /* trailing null */  + 1 /* Signature word */ ;
                name_len2 *= 2; /* convert to bytes */
        } else {        /* BB improve the check for buffer overruns BB */
-               name_len = strnlen(fromName, PATH_MAX);
+               name_len = strnlen(from_name, PATH_MAX);
                name_len++;     /* trailing null */
-               strncpy(pSMB->OldFileName, fromName, name_len);
-               name_len2 = strnlen(toName, PATH_MAX);
+               strncpy(pSMB->OldFileName, from_name, name_len);
+               name_len2 = strnlen(to_name, PATH_MAX);
                name_len2++;    /* trailing null */
                pSMB->OldFileName[name_len] = 0x04;     /* 2nd buffer format */
-               strncpy(&pSMB->OldFileName[name_len + 1], toName, name_len2);
+               strncpy(&pSMB->OldFileName[name_len + 1], to_name, name_len2);
                name_len2++;    /* trailing null */
                name_len2++;    /* signature byte */
        }
index e6ce3b1128756be4496494b2623fab27fa0d165f..51dc2fb6e854a724b16b782b6ab514446b8db7f5 100644 (file)
@@ -391,72 +391,86 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
 {
        int rc = -EACCES;
        unsigned int xid;
-       char *fromName = NULL;
-       char *toName = NULL;
+       char *from_name = NULL;
+       char *to_name = NULL;
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
        struct tcon_link *tlink;
-       struct cifs_tcon *pTcon;
+       struct cifs_tcon *tcon;
+       struct TCP_Server_Info *server;
        struct cifsInodeInfo *cifsInode;
 
        tlink = cifs_sb_tlink(cifs_sb);
        if (IS_ERR(tlink))
                return PTR_ERR(tlink);
-       pTcon = tlink_tcon(tlink);
+       tcon = tlink_tcon(tlink);
 
        xid = get_xid();
 
-       fromName = build_path_from_dentry(old_file);
-       toName = build_path_from_dentry(direntry);
-       if ((fromName == NULL) || (toName == NULL)) {
+       from_name = build_path_from_dentry(old_file);
+       to_name = build_path_from_dentry(direntry);
+       if ((from_name == NULL) || (to_name == NULL)) {
                rc = -ENOMEM;
                goto cifs_hl_exit;
        }
 
-       if (pTcon->unix_ext)
-               rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
+       if (tcon->unix_ext)
+               rc = CIFSUnixCreateHardLink(xid, tcon, from_name, to_name,
                                            cifs_sb->local_nls,
                                            cifs_sb->mnt_cifs_flags &
                                                CIFS_MOUNT_MAP_SPECIAL_CHR);
        else {
-               rc = CIFSCreateHardLink(xid, pTcon, fromName, toName,
-                                       cifs_sb->local_nls,
-                                       cifs_sb->mnt_cifs_flags &
-                                               CIFS_MOUNT_MAP_SPECIAL_CHR);
+               server = tcon->ses->server;
+               if (!server->ops->create_hardlink)
+                       return -ENOSYS;
+               rc = server->ops->create_hardlink(xid, tcon, from_name, to_name,
+                                                 cifs_sb);
                if ((rc == -EIO) || (rc == -EINVAL))
                        rc = -EOPNOTSUPP;
        }
 
        d_drop(direntry);       /* force new lookup from server of target */
 
-       /* if source file is cached (oplocked) revalidate will not go to server
-          until the file is closed or oplock broken so update nlinks locally */
+       /*
+        * if source file is cached (oplocked) revalidate will not go to server
+        * until the file is closed or oplock broken so update nlinks locally
+        */
        if (old_file->d_inode) {
                cifsInode = CIFS_I(old_file->d_inode);
                if (rc == 0) {
                        spin_lock(&old_file->d_inode->i_lock);
                        inc_nlink(old_file->d_inode);
                        spin_unlock(&old_file->d_inode->i_lock);
-/* BB should we make this contingent on superblock flag NOATIME? */
-/*                     old_file->d_inode->i_ctime = CURRENT_TIME;*/
-                       /* parent dir timestamps will update from srv
-                       within a second, would it really be worth it
-                       to set the parent dir cifs inode time to zero
-                       to force revalidate (faster) for it too? */
+                       /*
+                        * BB should we make this contingent on superblock flag
+                        * NOATIME?
+                        */
+                       /* old_file->d_inode->i_ctime = CURRENT_TIME; */
+                       /*
+                        * parent dir timestamps will update from srv within a
+                        * second, would it really be worth it to set the parent
+                        * dir cifs inode time to zero to force revalidate
+                        * (faster) for it too?
+                        */
                }
-               /* if not oplocked will force revalidate to get info
-                  on source file from srv */
+               /*
+                * if not oplocked will force revalidate to get info on source
+                * file from srv
+                */
                cifsInode->time = 0;
 
-               /* Will update parent dir timestamps from srv within a second.
-                  Would it really be worth it to set the parent dir (cifs
-                  inode) time field to zero to force revalidate on parent
-                  directory faster ie
-                       CIFS_I(inode)->time = 0;  */
+               /*
+                * Will update parent dir timestamps from srv within a second.
+                * Would it really be worth it to set the parent dir (cifs
+                * inode) time field to zero to force revalidate on parent
+                * directory faster ie
+                *
+                * CIFS_I(inode)->time = 0;
+                */
        }
 
 cifs_hl_exit:
-       kfree(fromName);
-       kfree(toName);
+       kfree(from_name);
+       kfree(to_name);
        free_xid(xid);
        cifs_put_tlink(tlink);
        return rc;
index 3773920036557704589bb31f8f1c92ab4df1cf8a..e5d63444f0ff2354de1a3d5f47efe2fc193753f4 100644 (file)
@@ -801,6 +801,7 @@ struct smb_version_operations smb1_operations = {
        .unlink = CIFSSMBDelFile,
        .rename_pending_delete = cifs_rename_pending_delete,
        .rename = CIFSSMBRename,
+       .create_hardlink = CIFSCreateHardLink,
        .open = cifs_open_file,
        .set_fid = cifs_set_fid,
        .close = cifs_close_file,