Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / fs / ncpfs / dir.c
index 9184fbb..f0860c6 100644 (file)
@@ -49,7 +49,7 @@ extern int ncp_symlink(struct inode *, struct dentry *, const char *);
 #define ncp_symlink NULL
 #endif
                      
-struct file_operations ncp_dir_operations =
+const struct file_operations ncp_dir_operations =
 {
        .read           = generic_read_dir,
        .readdir        = ncp_readdir,
@@ -174,7 +174,7 @@ ncp_force_unlink(struct inode *dir, struct dentry* dentry)
 {
         int res=0x9c,res2;
        struct nw_modify_dos_info info;
-       __u32 old_nwattr;
+       __le32 old_nwattr;
        struct inode *inode;
 
        memset(&info, 0, sizeof(info));
@@ -211,8 +211,8 @@ ncp_force_rename(struct inode *old_dir, struct dentry* old_dentry, char *_old_na
        struct nw_modify_dos_info info;
         int res=0x90,res2;
        struct inode *old_inode = old_dentry->d_inode;
-       __u32 old_nwattr = NCP_FINFO(old_inode)->nwattr;
-       __u32 new_nwattr = 0; /* shut compiler warning */
+       __le32 old_nwattr = NCP_FINFO(old_inode)->nwattr;
+       __le32 new_nwattr = 0; /* shut compiler warning */
        int old_nwattr_changed = 0;
        int new_nwattr_changed = 0;
 
@@ -365,7 +365,7 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
        spin_lock(&dcache_lock);
        next = parent->d_subdirs.next;
        while (next != &parent->d_subdirs) {
-               dent = list_entry(next, struct dentry, d_child);
+               dent = list_entry(next, struct dentry, d_u.d_child);
                if ((unsigned long)dent->d_fsdata == fpos) {
                        if (dent->d_inode)
                                dget_locked(dent);
@@ -395,8 +395,7 @@ static time_t ncp_obtain_mtime(struct dentry *dentry)
        if (ncp_obtain_info(server, inode, NULL, &i))
                return 0;
 
-       return ncp_date_dos2unix(le16_to_cpu(i.modifyTime),
-                                               le16_to_cpu(i.modifyDate));
+       return ncp_date_dos2unix(i.modifyTime, i.modifyDate);
 }
 
 static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
@@ -706,18 +705,6 @@ ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir,
                DPRINTK("ncp_do_readdir: init failed, err=%d\n", err);
                return;
        }
-#ifdef USE_OLD_SLOW_DIRECTORY_LISTING
-       for (;;) {
-               err = ncp_search_for_file_or_subdir(server, &seq, &entry.i);
-               if (err) {
-                       DPRINTK("ncp_do_readdir: search failed, err=%d\n", err);
-                       break;
-               }
-               entry.volume = entry.i.volNumber;
-               if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry))
-                       break;
-       }
-#else
        /* We MUST NOT use server->buffer_size handshaked with server if we are
           using UDP, as for UDP server uses max. buffer size determined by
           MTU, and for TCP server uses hardwired value 65KB (== 66560 bytes). 
@@ -755,19 +742,20 @@ ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir,
                }
        } while (more);
        vfree(buf);
-#endif
        return;
 }
 
 int ncp_conn_logged_in(struct super_block *sb)
 {
        struct ncp_server* server = NCP_SBP(sb);
-       struct nw_info_struct i;
        int result;
 
        if (ncp_single_volume(server)) {
                int len;
                struct dentry* dent;
+               __u32 volNumber;
+               __le32 dirEntNum;
+               __le32 DosDirNum;
                __u8 __name[NCP_MAXPATHLEN + 1];
 
                len = sizeof(__name);
@@ -776,7 +764,7 @@ int ncp_conn_logged_in(struct super_block *sb)
                if (result)
                        goto out;
                result = -ENOENT;
-               if (ncp_lookup_volume(server, __name, &i)) {
+               if (ncp_get_volume_root(server, __name, &volNumber, &dirEntNum, &DosDirNum)) {
                        PPRINTK("ncp_conn_logged_in: %s not found\n",
                                server->m.mounted_vol);
                        goto out;
@@ -785,9 +773,9 @@ int ncp_conn_logged_in(struct super_block *sb)
                if (dent) {
                        struct inode* ino = dent->d_inode;
                        if (ino) {
-                               NCP_FINFO(ino)->volNumber = i.volNumber;
-                               NCP_FINFO(ino)->dirEntNum = i.dirEntNum;
-                               NCP_FINFO(ino)->DosDirNum = i.DosDirNum;
+                               NCP_FINFO(ino)->volNumber = volNumber;
+                               NCP_FINFO(ino)->dirEntNum = dirEntNum;
+                               NCP_FINFO(ino)->DosDirNum = DosDirNum;
                        } else {
                                DPRINTK("ncpfs: sb->s_root->d_inode == NULL!\n");
                        }
@@ -886,7 +874,7 @@ out_close:
 }
 
 int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode,
-                  dev_t rdev, int attributes)
+                  dev_t rdev, __le32 attributes)
 {
        struct ncp_server *server = NCP_SERVER(dir);
        struct ncp_entry_info finfo;
@@ -979,7 +967,8 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 
        error = -EACCES;
        if (ncp_open_create_file_or_subdir(server, dir, __name,
-                                          OC_MODE_CREATE, aDIR, 0xffff,
+                                          OC_MODE_CREATE, aDIR,
+                                          cpu_to_le16(0xffff),
                                           &finfo) == 0)
        {
                if (ncp_is_nfs_extras(server, finfo.volume)) {
@@ -1213,8 +1202,9 @@ static int local2utc(int time)
 
 /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */
 int
-ncp_date_dos2unix(unsigned short time, unsigned short date)
+ncp_date_dos2unix(__le16 t, __le16 d)
 {
+       unsigned short time = le16_to_cpu(t), date = le16_to_cpu(d);
        int month, year, secs;
 
        /* first subtract and mask after that... Otherwise, if
@@ -1231,13 +1221,14 @@ ncp_date_dos2unix(unsigned short time, unsigned short date)
 
 /* Convert linear UNIX date to a MS-DOS time/date pair. */
 void
-ncp_date_unix2dos(int unix_date, unsigned short *time, unsigned short *date)
+ncp_date_unix2dos(int unix_date, __le16 *time, __le16 *date)
 {
        int day, year, nl_day, month;
 
        unix_date = utc2local(unix_date);
-       *time = (unix_date % 60) / 2 + (((unix_date / 60) % 60) << 5) +
-           (((unix_date / 3600) % 24) << 11);
+       *time = cpu_to_le16(
+               (unix_date % 60) / 2 + (((unix_date / 60) % 60) << 5) +
+               (((unix_date / 3600) % 24) << 11));
        day = unix_date / 86400 - 3652;
        year = day / 365;
        if ((year + 3) / 4 + 365 * year > day)
@@ -1252,5 +1243,5 @@ ncp_date_unix2dos(int unix_date, unsigned short *time, unsigned short *date)
                        if (day_n[month] > nl_day)
                                break;
        }
-       *date = nl_day - day_n[month - 1] + 1 + (month << 5) + (year << 9);
+       *date = cpu_to_le16(nl_day - day_n[month - 1] + 1 + (month << 5) + (year << 9));
 }