nfsd4: support putpubfh operation
[safe/jmp/linux-2.6] / fs / cifs / readdir.c
index b5a9bff..c2c01ff 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Directory search handling
  *
- *   Copyright (C) International Business Machines  Corp., 2004, 2007
+ *   Copyright (C) International Business Machines  Corp., 2004, 2008
  *   Author(s): Steve French (sfrench@us.ibm.com)
  *
  *   This library is free software; you can redistribute it and/or modify
@@ -42,48 +42,48 @@ static void dump_cifs_file_struct(struct file *file, char *label)
                        cFYI(1, ("empty cifs private file data"));
                        return;
                }
-               if (cf->invalidHandle) {
+               if (cf->invalidHandle)
                        cFYI(1, ("invalid handle"));
-               }
-               if (cf->srch_inf.endOfSearch) {
+               if (cf->srch_inf.endOfSearch)
                        cFYI(1, ("end of search"));
-               }
-               if (cf->srch_inf.emptyDir) {
+               if (cf->srch_inf.emptyDir)
                        cFYI(1, ("empty dir"));
-               }
        }
 }
+#else
+static inline void dump_cifs_file_struct(struct file *file, char *label)
+{
+}
 #endif /* DEBUG2 */
 
-/* Returns one if new inode created (which therefore needs to be hashed) */
+/* Returns 1 if new inode created, 2 if both dentry and inode were */
 /* Might check in the future if inode number changed so we can rehash inode */
-static int construct_dentry(struct qstr *qstring, struct file *file,
-       struct inode **ptmp_inode, struct dentry **pnew_dentry)
+static int
+construct_dentry(struct qstr *qstring, struct file *file,
+                struct inode **ptmp_inode, struct dentry **pnew_dentry,
+                __u64 *inum)
 {
-       struct dentry *tmp_dentry;
-       struct cifs_sb_info *cifs_sb;
-       struct cifsTconInfo *pTcon;
+       struct dentry *tmp_dentry = NULL;
+       struct super_block *sb = file->f_path.dentry->d_sb;
        int rc = 0;
 
        cFYI(1, ("For %s", qstring->name));
-       cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
-       pTcon = cifs_sb->tcon;
 
        qstring->hash = full_name_hash(qstring->name, qstring->len);
        tmp_dentry = d_lookup(file->f_path.dentry, qstring);
        if (tmp_dentry) {
+               /* BB: overwrite old name? i.e. tmp_dentry->d_name and
+                * tmp_dentry->d_name.len??
+                */
                cFYI(0, ("existing dentry with inode 0x%p",
                         tmp_dentry->d_inode));
                *ptmp_inode = tmp_dentry->d_inode;
-/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
                if (*ptmp_inode == NULL) {
-                       *ptmp_inode = new_inode(file->f_path.dentry->d_sb);
+                       *ptmp_inode = cifs_new_inode(sb, inum);
                        if (*ptmp_inode == NULL)
                                return rc;
                        rc = 1;
                }
-               if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
-                       (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
        } else {
                tmp_dentry = d_alloc(file->f_path.dentry, qstring);
                if (tmp_dentry == NULL) {
@@ -92,15 +92,14 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
                        return rc;
                }
 
-               *ptmp_inode = new_inode(file->f_path.dentry->d_sb);
-               if (pTcon->nocase)
+               if (CIFS_SB(sb)->tcon->nocase)
                        tmp_dentry->d_op = &cifs_ci_dentry_ops;
                else
                        tmp_dentry->d_op = &cifs_dentry_ops;
+
+               *ptmp_inode = cifs_new_inode(sb, inum);
                if (*ptmp_inode == NULL)
                        return rc;
-               if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
-                       (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
                rc = 2;
        }
 
@@ -121,7 +120,7 @@ static void AdjustForTZ(struct cifsTconInfo *tcon, struct inode *inode)
 
 
 static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
-                         char *buf, int *pobject_type, int isNewInode)
+                         char *buf, unsigned int *pobject_type, int isNewInode)
 {
        loff_t local_size;
        struct timespec local_mtime;
@@ -131,6 +130,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
        __u32 attr;
        __u64 allocation_size;
        __u64 end_of_file;
+       umode_t default_mode;
 
        /* save mtime and size */
        local_mtime = tmp_inode->i_mtime;
@@ -150,7 +150,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
                      cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
        } else { /* legacy, OS2 and DOS style */
 /*             struct timespec ts;*/
-               FIND_FILE_STANDARD_INFO * pfindData =
+               FIND_FILE_STANDARD_INFO *pfindData =
                        (FIND_FILE_STANDARD_INFO *)buf;
 
                tmp_inode->i_mtime = cnvrtDosUnixTm(
@@ -171,7 +171,13 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
        /* Linux can not store file creation time unfortunately so ignore it */
 
        cifsInfo->cifsAttrs = attr;
-       cifsInfo->time = jiffies;
+#ifdef CONFIG_CIFS_EXPERIMENTAL
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
+               /* get more accurate mode via ACL - so force inode refresh */
+               cifsInfo->time = 0;
+       } else
+#endif /* CONFIG_CIFS_EXPERIMENTAL */
+               cifsInfo->time = jiffies;
 
        /* treat dos attribute of read-only as read-only mode bit e.g. 555? */
        /* 2767 perms - indicate mandatory locking */
@@ -180,54 +186,58 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
        if (atomic_read(&cifsInfo->inUse) == 0) {
                tmp_inode->i_uid = cifs_sb->mnt_uid;
                tmp_inode->i_gid = cifs_sb->mnt_gid;
-               /* set default mode. will override for dirs below */
-               tmp_inode->i_mode = cifs_sb->mnt_file_mode;
-       } else {
-               /* mask off the type bits since it gets set
-               below and we do not want to get two type
-               bits set */
+       }
+
+       if (attr & ATTR_DIRECTORY)
+               default_mode = cifs_sb->mnt_dir_mode;
+       else
+               default_mode = cifs_sb->mnt_file_mode;
+
+       /* set initial permissions */
+       if ((atomic_read(&cifsInfo->inUse) == 0) ||
+           (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
+               tmp_inode->i_mode = default_mode;
+       else {
+               /* just reenable write bits if !ATTR_READONLY */
+               if ((tmp_inode->i_mode & S_IWUGO) == 0 &&
+                   (attr & ATTR_READONLY) == 0)
+                       tmp_inode->i_mode |= (S_IWUGO & default_mode);
+
                tmp_inode->i_mode &= ~S_IFMT;
        }
 
-       if (attr & ATTR_DIRECTORY) {
-               *pobject_type = DT_DIR;
-               /* override default perms since we do not lock dirs */
-               if (atomic_read(&cifsInfo->inUse) == 0) {
-                       tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
-               }
-               tmp_inode->i_mode |= S_IFDIR;
-       } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
-                  (attr & ATTR_SYSTEM)) {
+       /* clear write bits if ATTR_READONLY is set */
+       if (attr & ATTR_READONLY)
+               tmp_inode->i_mode &= ~S_IWUGO;
+
+       /* set inode type */
+       if ((attr & ATTR_SYSTEM) &&
+           (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) {
                if (end_of_file == 0)  {
-                       *pobject_type = DT_FIFO;
                        tmp_inode->i_mode |= S_IFIFO;
+                       *pobject_type = DT_FIFO;
                } else {
-                       /* rather than get the type here, we mark the
-                       inode as needing revalidate and get the real type
-                       (blk vs chr vs. symlink) later ie in lookup */
-                       *pobject_type = DT_REG;
+                       /*
+                        * trying to get the type can be slow, so just call
+                        * this a regular file for now, and mark for reval
+                        */
                        tmp_inode->i_mode |= S_IFREG;
+                       *pobject_type = DT_REG;
                        cifsInfo->time = 0;
                }
-/* we no longer mark these because we could not follow them */
-/*        } else if (attr & ATTR_REPARSE) {
-               *pobject_type = DT_LNK;
-               tmp_inode->i_mode |= S_IFLNK; */
        } else {
-               *pobject_type = DT_REG;
-               tmp_inode->i_mode |= S_IFREG;
-               if (attr & ATTR_READONLY)
-                       tmp_inode->i_mode &= ~(S_IWUGO);
-               else if ((tmp_inode->i_mode & S_IWUGO) == 0)
-                       /* the ATTR_READONLY flag may have been changed on   */
-                       /* server -- set any w bits allowed by mnt_file_mode */
-                       tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode);
-       } /* could add code here - to validate if device or weird share type? */
+               if (attr & ATTR_DIRECTORY) {
+                       tmp_inode->i_mode |= S_IFDIR;
+                       *pobject_type = DT_DIR;
+               } else {
+                       tmp_inode->i_mode |= S_IFREG;
+                       *pobject_type = DT_REG;
+               }
+       }
 
        /* can not fill in nlink here as in qpathinfo version and Unx search */
-       if (atomic_read(&cifsInfo->inUse) == 0) {
+       if (atomic_read(&cifsInfo->inUse) == 0)
                atomic_set(&cifsInfo->inUse, 1);
-       }
 
        spin_lock(&tmp_inode->i_lock);
        if (is_size_safe_to_change(cifsInfo, end_of_file)) {
@@ -294,7 +304,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
 }
 
 static void unix_fill_in_inode(struct inode *tmp_inode,
-       FILE_UNIX_INFO *pfindData, int *pobject_type, int isNewInode)
+       FILE_UNIX_INFO *pfindData, unsigned int *pobject_type, int isNewInode)
 {
        loff_t local_size;
        struct timespec local_mtime;
@@ -442,8 +452,8 @@ static int initiate_cifs_search(const int xid, struct file *file)
        if (file->private_data == NULL)
                return -ENOMEM;
        cifsFile = file->private_data;
-       cifsFile->invalidHandle = TRUE;
-       cifsFile->srch_inf.endOfSearch = FALSE;
+       cifsFile->invalidHandle = true;
+       cifsFile->srch_inf.endOfSearch = false;
 
        cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        if (cifs_sb == NULL)
@@ -455,9 +465,8 @@ static int initiate_cifs_search(const int xid, struct file *file)
 
        full_path = build_path_from_dentry(file->f_path.dentry);
 
-       if (full_path == NULL) {
+       if (full_path == NULL)
                return -ENOMEM;
-       }
 
        cFYI(1, ("Full path: %s start at: %lld", full_path, file->f_pos));
 
@@ -465,9 +474,9 @@ ffirst_retry:
        /* test for Unix extensions */
        /* but now check for them on the share/mount not on the SMB session */
 /*     if (pTcon->ses->capabilities & CAP_UNIX) { */
-       if (pTcon->unix_ext) {
+       if (pTcon->unix_ext)
                cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX;
-       else if ((pTcon->ses->capabilities &
+       else if ((pTcon->ses->capabilities &
                        (CAP_NT_SMBS | CAP_NT_FIND)) == 0) {
                cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD;
        } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
@@ -481,7 +490,7 @@ ffirst_retry:
                cifs_sb->mnt_cifs_flags &
                        CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
        if (rc == 0)
-               cifsFile->invalidHandle = FALSE;
+               cifsFile->invalidHandle = false;
        if ((rc == -EOPNOTSUPP) &&
                (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
                cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
@@ -495,7 +504,7 @@ ffirst_retry:
 static int cifs_unicode_bytelen(char *str)
 {
        int len;
-       __le16 * ustr = (__le16 *)str;
+       __le16 *ustr = (__le16 *)str;
 
        for (len = 0; len <= PATH_MAX; len++) {
                if (ustr[len] == 0)
@@ -508,10 +517,10 @@ static int cifs_unicode_bytelen(char *str)
 static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
 {
        char *new_entry;
-       FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
+       FILE_DIRECTORY_INFO *pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
 
        if (level == SMB_FIND_FILE_INFO_STANDARD) {
-               FIND_FILE_STANDARD_INFO * pfData;
+               FIND_FILE_STANDARD_INFO *pfData;
                pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo;
 
                new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) +
@@ -547,7 +556,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
        int len = 0;
 
        if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
-               FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
+               FILE_UNIX_INFO *pFindData = (FILE_UNIX_INFO *)current_entry;
                filename = &pFindData->FileName[0];
                if (cfile->srch_inf.unicode) {
                        len = cifs_unicode_bytelen(filename);
@@ -556,30 +565,30 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
                        len = strnlen(filename, 5);
                }
        } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) {
-               FILE_DIRECTORY_INFO * pFindData =
+               FILE_DIRECTORY_INFO *pFindData =
                        (FILE_DIRECTORY_INFO *)current_entry;
                filename = &pFindData->FileName[0];
                len = le32_to_cpu(pFindData->FileNameLength);
        } else if (cfile->srch_inf.info_level ==
                        SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
-               FILE_FULL_DIRECTORY_INFO * pFindData =
+               FILE_FULL_DIRECTORY_INFO *pFindData =
                        (FILE_FULL_DIRECTORY_INFO *)current_entry;
                filename = &pFindData->FileName[0];
                len = le32_to_cpu(pFindData->FileNameLength);
        } else if (cfile->srch_inf.info_level ==
                        SMB_FIND_FILE_ID_FULL_DIR_INFO) {
-               SEARCH_ID_FULL_DIR_INFO * pFindData =
+               SEARCH_ID_FULL_DIR_INFO *pFindData =
                        (SEARCH_ID_FULL_DIR_INFO *)current_entry;
                filename = &pFindData->FileName[0];
                len = le32_to_cpu(pFindData->FileNameLength);
        } else if (cfile->srch_inf.info_level ==
                        SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
-               FILE_BOTH_DIRECTORY_INFO * pFindData =
+               FILE_BOTH_DIRECTORY_INFO *pFindData =
                        (FILE_BOTH_DIRECTORY_INFO *)current_entry;
                filename = &pFindData->FileName[0];
                len = le32_to_cpu(pFindData->FileNameLength);
        } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) {
-               FIND_FILE_STANDARD_INFO * pFindData =
+               FIND_FILE_STANDARD_INFO *pFindData =
                        (FIND_FILE_STANDARD_INFO *)current_entry;
                filename = &pFindData->FileName[0];
                len = pFindData->FileNameLength;
@@ -629,6 +638,70 @@ static int is_dir_changed(struct file *file)
 
 }
 
+static int cifs_save_resume_key(const char *current_entry,
+       struct cifsFileInfo *cifsFile)
+{
+       int rc = 0;
+       unsigned int len = 0;
+       __u16 level;
+       char *filename;
+
+       if ((cifsFile == NULL) || (current_entry == NULL))
+               return -EINVAL;
+
+       level = cifsFile->srch_inf.info_level;
+
+       if (level == SMB_FIND_FILE_UNIX) {
+               FILE_UNIX_INFO *pFindData = (FILE_UNIX_INFO *)current_entry;
+
+               filename = &pFindData->FileName[0];
+               if (cifsFile->srch_inf.unicode) {
+                       len = cifs_unicode_bytelen(filename);
+               } else {
+                       /* BB should we make this strnlen of PATH_MAX? */
+                       len = strnlen(filename, PATH_MAX);
+               }
+               cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
+       } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
+               FILE_DIRECTORY_INFO *pFindData =
+                       (FILE_DIRECTORY_INFO *)current_entry;
+               filename = &pFindData->FileName[0];
+               len = le32_to_cpu(pFindData->FileNameLength);
+               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+       } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
+               FILE_FULL_DIRECTORY_INFO *pFindData =
+                       (FILE_FULL_DIRECTORY_INFO *)current_entry;
+               filename = &pFindData->FileName[0];
+               len = le32_to_cpu(pFindData->FileNameLength);
+               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+       } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
+               SEARCH_ID_FULL_DIR_INFO *pFindData =
+                       (SEARCH_ID_FULL_DIR_INFO *)current_entry;
+               filename = &pFindData->FileName[0];
+               len = le32_to_cpu(pFindData->FileNameLength);
+               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+       } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
+               FILE_BOTH_DIRECTORY_INFO *pFindData =
+                       (FILE_BOTH_DIRECTORY_INFO *)current_entry;
+               filename = &pFindData->FileName[0];
+               len = le32_to_cpu(pFindData->FileNameLength);
+               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
+       } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
+               FIND_FILE_STANDARD_INFO *pFindData =
+                       (FIND_FILE_STANDARD_INFO *)current_entry;
+               filename = &pFindData->FileName[0];
+               /* one byte length, no name conversion */
+               len = (unsigned int)pFindData->FileNameLength;
+               cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
+       } else {
+               cFYI(1, ("Unknown findfirst level %d", level));
+               return -EINVAL;
+       }
+       cifsFile->srch_inf.resume_name_len = len;
+       cifsFile->srch_inf.presume_name = filename;
+       return rc;
+}
+
 /* find the corresponding entry in the search */
 /* Note that the SMB server returns search entries for . and .. which
    complicates logic here if we choose to parse for them and we do not
@@ -660,18 +733,20 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
        . and .. for the root of a drive and for those we need
        to start two entries earlier */
 
-#ifdef CONFIG_CIFS_DEBUG2
        dump_cifs_file_struct(file, "In fce ");
-#endif
        if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) &&
             is_dir_changed(file)) ||
           (index_to_find < first_entry_in_buffer)) {
                /* close and restart search */
                cFYI(1, ("search backing up - close and restart search"));
-               cifsFile->invalidHandle = TRUE;
-               CIFSFindClose(xid, pTcon, cifsFile->netfid);
-               kfree(cifsFile->search_resume_name);
-               cifsFile->search_resume_name = NULL;
+               write_lock(&GlobalSMBSeslock);
+               if (!cifsFile->srch_inf.endOfSearch &&
+                   !cifsFile->invalidHandle) {
+                       cifsFile->invalidHandle = true;
+                       write_unlock(&GlobalSMBSeslock);
+                       CIFSFindClose(xid, pTcon, cifsFile->netfid);
+               } else
+                       write_unlock(&GlobalSMBSeslock);
                if (cifsFile->srch_inf.ntwrk_buf_start) {
                        cFYI(1, ("freeing SMB ff cache buf on search rewind"));
                        if (cifsFile->srch_inf.smallBuf)
@@ -680,6 +755,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
                        else
                                cifs_buf_release(cifsFile->srch_inf.
                                                ntwrk_buf_start);
+                       cifsFile->srch_inf.ntwrk_buf_start = NULL;
                }
                rc = initiate_cifs_search(xid, file);
                if (rc) {
@@ -687,13 +763,15 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
                                 rc));
                        return rc;
                }
+               cifs_save_resume_key(cifsFile->srch_inf.last_entry, cifsFile);
        }
 
        while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
-             (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)) {
+             (rc == 0) && !cifsFile->srch_inf.endOfSearch) {
                cFYI(1, ("calling findnext2"));
                rc = CIFSFindNext(xid, pTcon, cifsFile->netfid,
                                  &cifsFile->srch_inf);
+               cifs_save_resume_key(cifsFile->srch_inf.last_entry, cifsFile);
                if (rc)
                        return -ENOENT;
        }
@@ -712,7 +790,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
                pos_in_buf = index_to_find - first_entry_in_buffer;
                cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf));
 
-               for (i=0; (i < (pos_in_buf)) && (current_entry != NULL); i++) {
+               for (i = 0; (i < (pos_in_buf)) && (current_entry != NULL); i++) {
                        /* go entry by entry figuring out which is first */
                        current_entry = nxt_dir_entry(current_entry, end_of_smb,
                                                cifsFile->srch_inf.info_level);
@@ -742,7 +820,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
 /* inode num, inode type and filename returned */
 static int cifs_get_name_from_search_buf(struct qstr *pqst,
        char *current_entry, __u16 level, unsigned int unicode,
-       struct cifs_sb_info *cifs_sb, int max_len, ino_t *pinum)
+       struct cifs_sb_info *cifs_sb, int max_len, __u64 *pinum)
 {
        int rc = 0;
        unsigned int len = 0;
@@ -762,9 +840,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
                        len = strnlen(filename, PATH_MAX);
                }
 
-               /* BB fixme - hash low and high 32 bits if not 64 bit arch BB */
-               if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
-                       *pinum = pFindData->UniqueId;
+               *pinum = pFindData->UniqueId;
        } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
                FILE_DIRECTORY_INFO *pFindData =
                        (FILE_DIRECTORY_INFO *)current_entry;
@@ -787,7 +863,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
                filename = &pFindData->FileName[0];
                len = le32_to_cpu(pFindData->FileNameLength);
        } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
-               FIND_FILE_STANDARD_INFO * pFindData =
+               FIND_FILE_STANDARD_INFO *pFindData =
                        (FIND_FILE_STANDARD_INFO *)current_entry;
                filename = &pFindData->FileName[0];
                /* one byte length, no name conversion */
@@ -826,8 +902,8 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
        int rc = 0;
        struct qstr qstring;
        struct cifsFileInfo *pCifsF;
-       unsigned obj_type;
-       ino_t  inum;
+       unsigned int obj_type;
+       __u64  inum;
        struct cifs_sb_info *cifs_sb;
        struct inode *tmp_inode;
        struct dentry *tmp_dentry;
@@ -860,20 +936,18 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
        if (rc)
                return rc;
 
-       rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry);
+       /* only these two infolevels return valid inode numbers */
+       if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX ||
+           pCifsF->srch_inf.info_level == SMB_FIND_FILE_ID_FULL_DIR_INFO)
+               rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry,
+                                       &inum);
+       else
+               rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry,
+                                       NULL);
+
        if ((tmp_inode == NULL) || (tmp_dentry == NULL))
                return -ENOMEM;
 
-       if (rc) {
-               /* inode created, we need to hash it with right inode number */
-               if (inum != 0) {
-                       /* BB fixme - hash the 2 32 quantities bits together if
-                        *  necessary BB */
-                       tmp_inode->i_ino = inum;
-               }
-               insert_inode_hash(tmp_inode);
-       }
-
        /* we pass in rc below, indicating whether it is a new inode,
           so we can figure out whether to invalidate the inode cached
           data if the file has changed */
@@ -908,69 +982,6 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
        return rc;
 }
 
-static int cifs_save_resume_key(const char *current_entry,
-       struct cifsFileInfo *cifsFile)
-{
-       int rc = 0;
-       unsigned int len = 0;
-       __u16 level;
-       char *filename;
-
-       if ((cifsFile == NULL) || (current_entry == NULL))
-               return -EINVAL;
-
-       level = cifsFile->srch_inf.info_level;
-
-       if (level == SMB_FIND_FILE_UNIX) {
-               FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
-
-               filename = &pFindData->FileName[0];
-               if (cifsFile->srch_inf.unicode) {
-                       len = cifs_unicode_bytelen(filename);
-               } else {
-                       /* BB should we make this strnlen of PATH_MAX? */
-                       len = strnlen(filename, PATH_MAX);
-               }
-               cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
-       } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
-               FILE_DIRECTORY_INFO *pFindData =
-                       (FILE_DIRECTORY_INFO *)current_entry;
-               filename = &pFindData->FileName[0];
-               len = le32_to_cpu(pFindData->FileNameLength);
-               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
-       } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
-               FILE_FULL_DIRECTORY_INFO *pFindData =
-                       (FILE_FULL_DIRECTORY_INFO *)current_entry;
-               filename = &pFindData->FileName[0];
-               len = le32_to_cpu(pFindData->FileNameLength);
-               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
-       } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
-               SEARCH_ID_FULL_DIR_INFO *pFindData =
-                       (SEARCH_ID_FULL_DIR_INFO *)current_entry;
-               filename = &pFindData->FileName[0];
-               len = le32_to_cpu(pFindData->FileNameLength);
-               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
-       } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
-               FILE_BOTH_DIRECTORY_INFO *pFindData =
-                       (FILE_BOTH_DIRECTORY_INFO *)current_entry;
-               filename = &pFindData->FileName[0];
-               len = le32_to_cpu(pFindData->FileNameLength);
-               cifsFile->srch_inf.resume_key = pFindData->FileIndex;
-       } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
-               FIND_FILE_STANDARD_INFO *pFindData =
-                       (FIND_FILE_STANDARD_INFO *)current_entry;
-               filename = &pFindData->FileName[0];
-               /* one byte length, no name conversion */
-               len = (unsigned int)pFindData->FileNameLength;
-               cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
-       } else {
-               cFYI(1, ("Unknown findfirst level %d", level));
-               return -EINVAL;
-       }
-       cifsFile->srch_inf.resume_name_len = len;
-       cifsFile->srch_inf.presume_name = filename;
-       return rc;
-}
 
 int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
 {
@@ -1036,11 +1047,9 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
                                break;
                        }
                } /* else {
-                       cifsFile->invalidHandle = TRUE;
+                       cifsFile->invalidHandle = true;
                        CIFSFindClose(xid, pTcon, cifsFile->netfid);
-               }
-               kfree(cifsFile->search_resume_name);
-               cifsFile->search_resume_name = NULL; */
+               } */
 
                rc = find_cifs_entry(xid, pTcon, file,
                                &current_entry, &num_to_fill);