Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 291263 Details for
Bug 247204
[PATCH] cifs / smbfs, mount error 20, NAS device only supports smb
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
cifs 1.50c as a patch against fedora 7 kernel rpm
cifs150c.patch (text/plain), 120.61 KB, created by
Kai Engert (:kaie) (inactive account)
on 2008-01-10 10:51:40 UTC
(
hide
)
Description:
cifs 1.50c as a patch against fedora 7 kernel rpm
Filename:
MIME Type:
Creator:
Kai Engert (:kaie) (inactive account)
Created:
2008-01-10 10:51:40 UTC
Size:
120.61 KB
patch
obsolete
>diff -r -Nu kernel-2.6.23.12-52.fc7/cifs-150c-plus.patch kernel-2.6.23.12-52.bug247204.fc7/cifs-150c-plus.patch >--- kernel-2.6.23.12-52.fc7/cifs-150c-plus.patch 1970-01-01 01:00:00.000000000 +0100 >+++ kernel-2.6.23.12-52.bug247204.fc7/cifs-150c-plus.patch 2008-01-09 17:45:37.000000000 +0100 >@@ -0,0 +1,3696 @@ >+diff -up linux-2.6.23.i386/fs/cifs/transport.c.pre150c linux-2.6.23.i386/fs/cifs/transport.c >+--- linux-2.6.23.i386/fs/cifs/transport.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/transport.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -27,13 +27,19 @@ >+ #include <linux/delay.h> >+ #include <asm/uaccess.h> >+ #include <asm/processor.h> >+-#include <linux/mempool.h> >+ #include "cifspdu.h" >+ #include "cifsglob.h" >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >++#include <linux/mempool.h> >++#else >++extern kmem_cache_t *cifs_mid_cachep; >++#endif >+ #include "cifsproto.h" >+ #include "cifs_debug.h" >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ extern mempool_t *cifs_mid_poolp; >++#endif >+ extern struct kmem_cache *cifs_oplock_cachep; >+ >+ static struct mid_q_entry * >+@@ -50,8 +56,14 @@ AllocMidQEntry(const struct smb_hdr *smb >+ return NULL; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ temp = (struct mid_q_entry *) mempool_alloc(cifs_mid_poolp, >+ GFP_KERNEL | GFP_NOFS); >++#else >++ temp = (struct mid_q_entry *) kmem_cache_alloc(cifs_mid_cachep, >++ SLAB_KERNEL); >++#endif >++ >+ if (temp == NULL) >+ return temp; >+ else { >+@@ -106,7 +118,11 @@ DeleteMidQEntry(struct mid_q_entry *midE >+ } >+ } >+ #endif >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ mempool_free(midEntry, cifs_mid_poolp); >++#else >++ kmem_cache_free(cifs_mid_cachep, midEntry); >++#endif >+ } >+ >+ struct oplock_q_entry * >+@@ -151,6 +167,9 @@ smb_send(struct socket *ssocket, struct >+ struct msghdr smb_msg; >+ struct kvec iov; >+ unsigned len = smb_buf_length + 4; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ mm_segment_t temp_fs; >++#endif >+ >+ if (ssocket == NULL) >+ return -ENOTSOCK; /* BB eventually add reconnect code here */ >+@@ -159,6 +178,10 @@ smb_send(struct socket *ssocket, struct >+ >+ smb_msg.msg_name = sin; >+ smb_msg.msg_namelen = sizeof (struct sockaddr); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ smb_msg.msg_iov = &iov; >++ smb_msg.msg_iovlen = 1; >++#endif >+ smb_msg.msg_control = NULL; >+ smb_msg.msg_controllen = 0; >+ smb_msg.msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL; /* BB add more flags?*/ >+@@ -172,8 +195,16 @@ smb_send(struct socket *ssocket, struct >+ cFYI(1, ("Sending smb of length %d", smb_buf_length)); >+ dump_smb(smb_buffer, len); >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ temp_fs = get_fs(); /* we must turn off socket api parm checking */ >++ set_fs(get_ds()); >++#endif >+ while (len > 0) { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ rc = sock_sendmsg(ssocket, &smb_msg, len); >++#else >+ rc = kernel_sendmsg(ssocket, &smb_msg, &iov, 1, len); >++#endif >+ if ((rc == -ENOSPC) || (rc == -EAGAIN)) { >+ i++; >+ /* smaller timeout here than send2 since smaller size */ >+@@ -197,6 +228,9 @@ smb_send(struct socket *ssocket, struct >+ iov.iov_len -= rc; >+ len -= rc; >+ } >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ set_fs(temp_fs); >++#endif >+ >+ if (rc < 0) { >+ cERROR(1, ("Error %d sending data on socket to server", rc)); >+@@ -223,6 +257,9 @@ smb_send2(struct socket *ssocket, struct >+ unsigned int total_len; >+ int first_vec = 0; >+ unsigned int smb_buf_length = smb_buffer->smb_buf_length; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ mm_segment_t temp_fs; >++#endif >+ >+ if (ssocket == NULL) >+ return -ENOTSOCK; /* BB eventually add reconnect code here */ >+@@ -247,9 +284,19 @@ smb_send2(struct socket *ssocket, struct >+ cFYI(1, ("Sending smb: total_len %d", total_len)); >+ dump_smb(smb_buffer, len); >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ temp_fs = get_fs(); /* we must turn off socket api parm checking */ >++ set_fs(get_ds()); >++#endif >+ while (total_len) { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ smb_msg.msg_iov = &iov[first_vec]; >++ smb_msg.msg_iovlen = n_vec - first_vec; >++ rc = sock_sendmsg(ssocket, &smb_msg, total_len); >++#else >+ rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec], >+ n_vec - first_vec, total_len); >++#endif >+ if ((rc == -ENOSPC) || (rc == -EAGAIN)) { >+ i++; >+ if (i >= 14) { >+@@ -293,6 +340,9 @@ smb_send2(struct socket *ssocket, struct >+ } >+ i = 0; /* in case we get ENOSPC on the next send */ >+ } >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ set_fs(temp_fs); >++#endif >+ >+ if (rc < 0) { >+ cERROR(1, ("Error %d sending data on socket to server", rc)); >+@@ -363,9 +413,8 @@ static int allocate_mid(struct cifsSesIn >+ } /* else ok - we are setting up session */ >+ } >+ *ppmidQ = AllocMidQEntry(in_buf, ses); >+- if (*ppmidQ == NULL) { >++ if (*ppmidQ == NULL) >+ return -ENOMEM; >+- } >+ return 0; >+ } >+ >+@@ -572,9 +621,8 @@ SendReceive2(const unsigned int xid, str >+ rc = map_smb_to_linux_error(midQ->resp_buf); >+ >+ /* convert ByteCount if necessary */ >+- if (receive_len >= >+- sizeof (struct smb_hdr) - >+- 4 /* do not count RFC1001 header */ + >++ if (receive_len >= sizeof(struct smb_hdr) - 4 >++ /* do not count RFC1001 header */ + >+ (2 * midQ->resp_buf->WordCount) + 2 /* bcc */ ) >+ BCC(midQ->resp_buf) = >+ le16_to_cpu(BCC_LE(midQ->resp_buf)); >+@@ -752,9 +800,8 @@ SendReceive(const unsigned int xid, stru >+ rc = map_smb_to_linux_error(out_buf); >+ >+ /* convert ByteCount if necessary */ >+- if (receive_len >= >+- sizeof (struct smb_hdr) - >+- 4 /* do not count RFC1001 header */ + >++ if (receive_len >= sizeof(struct smb_hdr) - 4 >++ /* do not count RFC1001 header */ + >+ (2 * out_buf->WordCount) + 2 /* bcc */ ) >+ BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf)); >+ } else { >+@@ -996,9 +1043,8 @@ SendReceiveBlockingLock(const unsigned i >+ rc = map_smb_to_linux_error(out_buf); >+ >+ /* convert ByteCount if necessary */ >+- if (receive_len >= >+- sizeof (struct smb_hdr) - >+- 4 /* do not count RFC1001 header */ + >++ if (receive_len >= sizeof(struct smb_hdr) - 4 >++ /* do not count RFC1001 header */ + >+ (2 * out_buf->WordCount) + 2 /* bcc */ ) >+ BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf)); >+ } else { >+diff -up linux-2.6.23.i386/fs/cifs/file.c.pre150c linux-2.6.23.i386/fs/cifs/file.c >+--- linux-2.6.23.i386/fs/cifs/file.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/file.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -22,16 +22,25 @@ >+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ */ >+ #include <linux/fs.h> >+-#include <linux/backing-dev.h> >+ #include <linux/stat.h> >+ #include <linux/fcntl.h> >+ #include <linux/pagemap.h> >+-#include <linux/pagevec.h> >+-#include <linux/writeback.h> >+-#include <linux/task_io_accounting_ops.h> >+ #include <linux/delay.h> >+ #include <asm/div64.h> >+ #include "cifsfs.h" >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >++#include <linux/backing-dev.h> >++#include <linux/mpage.h> >++#include <linux/pagevec.h> >++#include <linux/writeback.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19) >++#include <linux/task_io_accounting_ops.h> >++#endif /* 2.6.19 */ >++#endif >++#include <asm/uaccess.h> >++#ifndef FL_SLEEP >++#define FL_SLEEP 0 >++#endif >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+ #include "cifsproto.h" >+@@ -47,7 +56,11 @@ static inline struct cifsFileInfo *cifs_ >+ private_data->netfid = netfid; >+ private_data->pid = current->tgid; >+ init_MUTEX(&private_data->fh_sem); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ mutex_init(&private_data->lock_mutex); >++#else >++ init_MUTEX(&private_data->lock_mutex); >++#endif >+ INIT_LIST_HEAD(&private_data->llist); >+ private_data->pfile = file; /* needed for writepage */ >+ private_data->pInode = inode; >+@@ -81,7 +94,11 @@ static inline int cifs_convert_flags(uns >+ static inline int cifs_get_disposition(unsigned int flags) >+ { >+ if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ return FILE_CREATE; >++#else >++ return FILE_OPEN_IF; >++#endif >+ else if ((flags & (O_CREAT | O_TRUNC)) == (O_CREAT | O_TRUNC)) >+ return FILE_OVERWRITE_IF; >+ else if ((flags & O_CREAT) == O_CREAT) >+@@ -98,7 +115,11 @@ static inline int cifs_open_inode_helper >+ struct cifsTconInfo *pTcon, int *oplock, FILE_ALL_INFO *buf, >+ char *full_path, int xid) >+ { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct timespec temp; >++#else >++ time_t temp; >++#endif >+ int rc; >+ >+ /* want handles we can use to read with first >+@@ -122,34 +143,67 @@ static inline int cifs_open_inode_helper >+ /* if not oplocked, invalidate inode pages if mtime or file >+ size changed */ >+ temp = cifs_NTtimeToUnix(le64_to_cpu(buf->LastWriteTime)); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ if (timespec_equal(&file->f_dentry->d_inode->i_mtime, &temp) && >++ (file->f_dentry->d_inode->i_size == >++ (loff_t)le64_to_cpu(buf->EndOfFile))) { >++ cFYI(1, ("inode unchanged on server")); >++ } else { >++ if (file->f_dentry->d_inode->i_mapping) { >++#else >+ if (timespec_equal(&file->f_path.dentry->d_inode->i_mtime, &temp) && >+ (file->f_path.dentry->d_inode->i_size == >+ (loff_t)le64_to_cpu(buf->EndOfFile))) { >+ cFYI(1, ("inode unchanged on server")); >+ } else { >+ if (file->f_path.dentry->d_inode->i_mapping) { >++#endif >+ /* BB no need to lock inode until after invalidate >+ since namei code should already have it locked? */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19) >+ filemap_write_and_wait(file->f_path.dentry->d_inode->i_mapping); >++#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 15) >++ filemap_write_and_wait(file->f_dentry->d_inode->i_mapping); >++#else >++ filemap_fdatawrite(file->f_dentry->d_inode->i_mapping); >++ filemap_fdatawait(file->f_dentry->d_inode->i_mapping); >++#endif >+ } >+ cFYI(1, ("invalidating remote inode since open detected it " >+ "changed")); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ invalidate_remote_inode(file->f_dentry->d_inode); >++#else >+ invalidate_remote_inode(file->f_path.dentry->d_inode); >++#endif >+ } >+ >+ client_can_cache: >+ if (pTcon->unix_ext) >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ rc = cifs_get_inode_info_unix(&file->f_dentry->d_inode, >++#else >+ rc = cifs_get_inode_info_unix(&file->f_path.dentry->d_inode, >++#endif >+ full_path, inode->i_sb, xid); >+- else >++ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ rc = cifs_get_inode_info(&file->f_dentry->d_inode, >++#else >+ rc = cifs_get_inode_info(&file->f_path.dentry->d_inode, >++#endif >+ full_path, buf, inode->i_sb, xid); >+ >+ if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) { >+ pCifsInode->clientCanCacheAll = TRUE; >+ pCifsInode->clientCanCacheRead = TRUE; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cFYI(1, ("Exclusive Oplock granted on inode %p", >++ file->f_dentry->d_inode)); >++#else >+ cFYI(1, ("Exclusive Oplock granted on inode %p", >+ file->f_path.dentry->d_inode)); >++#endif >+ } else if ((*oplock & 0xF) == OPLOCK_READ) >+ pCifsInode->clientCanCacheRead = TRUE; >+ >+@@ -178,7 +232,11 @@ int cifs_open(struct inode *inode, struc >+ >+ if (file->f_flags & O_CREAT) { >+ /* search inode for this file and fill in file->private_data */ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ pCifsInode = CIFS_I(file->f_dentry->d_inode); >++#else >+ pCifsInode = CIFS_I(file->f_path.dentry->d_inode); >++#endif >+ read_lock(&GlobalSMBSeslock); >+ list_for_each(tmp, &pCifsInode->openFileList) { >+ pCifsFile = list_entry(tmp, struct cifsFileInfo, >+@@ -206,7 +264,11 @@ int cifs_open(struct inode *inode, struc >+ } >+ } >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ full_path = build_path_from_dentry(file->f_dentry); >++#else >+ full_path = build_path_from_dentry(file->f_path.dentry); >++#endif >+ if (full_path == NULL) { >+ FreeXid(xid); >+ return -ENOMEM; >+@@ -291,7 +353,11 @@ int cifs_open(struct inode *inode, struc >+ write_lock(&GlobalSMBSeslock); >+ list_add(&pCifsFile->tlist, &pTcon->openFileList); >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ pCifsInode = CIFS_I(file->f_dentry->d_inode); >++#else >+ pCifsInode = CIFS_I(file->f_path.dentry->d_inode); >++#endif >+ if (pCifsInode) { >+ rc = cifs_open_inode_helper(inode, file, pCifsInode, >+ pCifsFile, pTcon, >+@@ -364,6 +430,31 @@ static int cifs_reopen_file(struct file >+ return 0; >+ } >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ if (file->f_dentry == NULL) { >++ cERROR(1, ("no valid name if dentry freed")); >++ dump_stack(); >++ rc = -EBADF; >++ goto reopen_error_exit; >++ } >++ >++ inode = file->f_dentry->d_inode; >++ if (inode == NULL) { >++ cERROR(1, ("inode not valid")); >++ dump_stack(); >++ rc = -EBADF; >++ goto reopen_error_exit; >++ } >++ >++ cifs_sb = CIFS_SB(inode->i_sb); >++ pTcon = cifs_sb->tcon; >++ >++/* can not grab rename sem here because various ops, including >++ those that already have the rename sem can end up causing writepage >++ to get called and if the server was down that means we end up here, >++ and we can never tell if the caller already has the rename_sem */ >++ full_path = build_path_from_dentry(file->f_dentry); >++#else >+ if (file->f_path.dentry == NULL) { >+ cERROR(1, ("no valid name if dentry freed")); >+ dump_stack(); >+@@ -387,6 +478,7 @@ static int cifs_reopen_file(struct file >+ to get called and if the server was down that means we end up here, >+ and we can never tell if the caller already has the rename_sem */ >+ full_path = build_path_from_dentry(file->f_path.dentry); >++#endif >+ if (full_path == NULL) { >+ rc = -ENOMEM; >+ reopen_error_exit: >+@@ -425,7 +517,12 @@ reopen_error_exit: >+ pCifsInode = CIFS_I(inode); >+ if (pCifsInode) { >+ if (can_flush) { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 15) >+ filemap_write_and_wait(inode->i_mapping); >++#else >++ filemap_fdatawrite(inode->i_mapping); >++ filemap_fdatawait(inode->i_mapping); >++#endif >+ /* temporarily disable caching while we >+ go to server to get inode info */ >+ pCifsInode->clientCanCacheAll = FALSE; >+@@ -446,8 +543,13 @@ reopen_error_exit: >+ if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { >+ pCifsInode->clientCanCacheAll = TRUE; >+ pCifsInode->clientCanCacheRead = TRUE; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cFYI(1, ("Exclusive Oplock granted on inode %p", >++ file->f_dentry->d_inode)); >++#else >+ cFYI(1, ("Exclusive Oplock granted on inode %p", >+ file->f_path.dentry->d_inode)); >++#endif >+ } else if ((oplock & 0xF) == OPLOCK_READ) { >+ pCifsInode->clientCanCacheRead = TRUE; >+ pCifsInode->clientCanCacheAll = FALSE; >+@@ -467,7 +569,7 @@ reopen_error_exit: >+ int cifs_close(struct inode *inode, struct file *file) >+ { >+ int rc = 0; >+- int xid; >++ int xid, timeout; >+ struct cifs_sb_info *cifs_sb; >+ struct cifsTconInfo *pTcon; >+ struct cifsFileInfo *pSMBFile = >+@@ -485,9 +587,9 @@ int cifs_close(struct inode *inode, stru >+ /* no sense reconnecting to close a file that is >+ already closed */ >+ if (pTcon->tidStatus != CifsNeedReconnect) { >+- int timeout = 2; >++ timeout = 2; >+ while ((atomic_read(&pSMBFile->wrtPending) != 0) >+- && (timeout < 1000) ) { >++ && (timeout <= 2048)) { >+ /* Give write a better chance to get to >+ server ahead of the close. We do not >+ want to add a wait_q here as it would >+@@ -522,12 +624,30 @@ int cifs_close(struct inode *inode, stru >+ list_del(&pSMBFile->flist); >+ list_del(&pSMBFile->tlist); >+ write_unlock(&GlobalSMBSeslock); >++ timeout = 10; >++ /* We waited above to give the SMBWrite a chance to issue >++ on the wire (so we do not get SMBWrite returning EBADF >++ if writepages is racing with close. Note that writepages >++ does not specify a file handle, so it is possible for a file >++ to be opened twice, and the application close the "wrong" >++ file handle - in these cases we delay long enough to allow >++ the SMBWrite to get on the wire before the SMB Close. >++ We allow total wait here over 45 seconds, more than >++ oplock break time, and more than enough to allow any write >++ to complete on the server, or to time out on the client */ >++ while ((atomic_read(&pSMBFile->wrtPending) != 0) >++ && (timeout <= 50000)) { >++ cERROR(1, ("writes pending, delay free of handle")); >++ msleep(timeout); >++ timeout *= 8; >++ } >+ kfree(pSMBFile->search_resume_name); >+ kfree(file->private_data); >+ file->private_data = NULL; >+ } else >+ rc = -EBADF; >+ >++ read_lock(&GlobalSMBSeslock); >+ if (list_empty(&(CIFS_I(inode)->openFileList))) { >+ cFYI(1, ("closing last open instance for inode %p", inode)); >+ /* if the file is not open we do not know if we can cache info >+@@ -535,6 +655,7 @@ int cifs_close(struct inode *inode, stru >+ CIFS_I(inode)->clientCanCacheRead = FALSE; >+ CIFS_I(inode)->clientCanCacheAll = FALSE; >+ } >++ read_unlock(&GlobalSMBSeslock); >+ if ((rc == 0) && CIFS_I(inode)->write_behind_rc) >+ rc = CIFS_I(inode)->write_behind_rc; >+ FreeXid(xid); >+@@ -556,7 +677,11 @@ int cifs_closedir(struct inode *inode, s >+ if (pCFileStruct) { >+ struct cifsTconInfo *pTcon; >+ struct cifs_sb_info *cifs_sb = >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ CIFS_SB(file->f_dentry->d_sb); >++#else >+ CIFS_SB(file->f_path.dentry->d_sb); >++#endif >+ >+ pTcon = cifs_sb->tcon; >+ >+@@ -670,7 +795,11 @@ int cifs_lock(struct file *file, int cmd >+ } else >+ cFYI(1, ("Unknown type of lock")); >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >++#endif >+ pTcon = cifs_sb->tcon; >+ >+ if (file->private_data == NULL) { >+@@ -767,7 +896,8 @@ int cifs_lock(struct file *file, int cmd >+ mutex_lock(&fid->lock_mutex); >+ list_for_each_entry_safe(li, tmp, &fid->llist, llist) { >+ if (pfLock->fl_start <= li->offset && >+- length >= li->length) { >++ (pfLock->fl_start + length) >= >++ (li->offset + li->length)) { >+ stored_rc = CIFSSMBLock(xid, pTcon, >+ netfid, >+ li->length, li->offset, >+@@ -783,8 +913,10 @@ int cifs_lock(struct file *file, int cmd >+ } >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) >+ if (pfLock->fl_flags & FL_POSIX) >+ posix_lock_file_wait(file, pfLock); >++#endif >+ FreeXid(xid); >+ return rc; >+ } >+@@ -800,7 +932,11 @@ ssize_t cifs_user_write(struct file *fil >+ int xid, long_op; >+ struct cifsFileInfo *open_file; >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >++#endif >+ >+ pTcon = cifs_sb->tcon; >+ >+@@ -814,7 +950,11 @@ ssize_t cifs_user_write(struct file *fil >+ >+ xid = GetXid(); >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ if (*poffset > file->f_dentry->d_inode->i_size) >++#else >+ if (*poffset > file->f_path.dentry->d_inode->i_size) >++#endif >+ long_op = 2; /* writes past end of file can take a long time */ >+ else >+ long_op = 1; >+@@ -871,6 +1011,21 @@ ssize_t cifs_user_write(struct file *fil >+ cifs_stats_bytes_written(pTcon, total_written); >+ >+ /* since the write may have blocked check these pointers again */ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ if ((file->f_dentry) && (file->f_dentry->d_inode)) { >++ struct inode *inode = file->f_dentry->d_inode; >++/* Do not update local mtime - server will set its actual value on write >++ * inode->i_ctime = inode->i_mtime = >++ * current_fs_time(inode->i_sb);*/ >++ if (total_written > 0) { >++ spin_lock(&inode->i_lock); >++ if (*poffset > file->f_dentry->d_inode->i_size) >++ i_size_write(file->f_dentry->d_inode, >++ *poffset); >++ spin_unlock(&inode->i_lock); >++ } >++ mark_inode_dirty_sync(file->f_dentry->d_inode); >++#else >+ if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) { >+ struct inode *inode = file->f_path.dentry->d_inode; >+ /* Do not update local mtime - server will set its actual value on write >+@@ -884,6 +1039,7 @@ ssize_t cifs_user_write(struct file *fil >+ spin_unlock(&inode->i_lock); >+ } >+ mark_inode_dirty_sync(file->f_path.dentry->d_inode); >++#endif >+ } >+ FreeXid(xid); >+ return total_written; >+@@ -900,6 +1056,22 @@ static ssize_t cifs_write(struct file *f >+ int xid, long_op; >+ struct cifsFileInfo *open_file; >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++ >++ pTcon = cifs_sb->tcon; >++ >++ cFYI(1, ("write %zd bytes to offset %lld of %s", write_size, >++ *poffset, file->f_dentry->d_name.name)); >++ >++ if (file->private_data == NULL) >++ return -EBADF; >++ open_file = (struct cifsFileInfo *)file->private_data; >++ >++ xid = GetXid(); >++ >++ if (*poffset > file->f_dentry->d_inode->i_size) >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >+ >+ pTcon = cifs_sb->tcon; >+@@ -914,6 +1086,7 @@ static ssize_t cifs_write(struct file *f >+ xid = GetXid(); >+ >+ if (*poffset > file->f_path.dentry->d_inode->i_size) >++#endif >+ long_op = 2; /* writes past end of file can take a long time */ >+ else >+ long_op = 1; >+@@ -989,6 +1162,20 @@ static ssize_t cifs_write(struct file *f >+ cifs_stats_bytes_written(pTcon, total_written); >+ >+ /* since the write may have blocked check these pointers again */ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ if ((file->f_dentry) && (file->f_dentry->d_inode)) { >++/*BB We could make this contingent on superblock ATIME flag too */ >++/* file->f_dentry->d_inode->i_ctime = >++ file->f_dentry->d_inode->i_mtime = CURRENT_TIME;*/ >++ if (total_written > 0) { >++ spin_lock(&file->f_dentry->d_inode->i_lock); >++ if (*poffset > file->f_dentry->d_inode->i_size) >++ i_size_write(file->f_dentry->d_inode, >++ *poffset); >++ spin_unlock(&file->f_dentry->d_inode->i_lock); >++ } >++ mark_inode_dirty_sync(file->f_dentry->d_inode); >++#else >+ if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) { >+ /*BB We could make this contingent on superblock ATIME flag too */ >+ /* file->f_path.dentry->d_inode->i_ctime = >+@@ -1001,6 +1188,7 @@ static ssize_t cifs_write(struct file *f >+ spin_unlock(&file->f_path.dentry->d_inode->i_lock); >+ } >+ mark_inode_dirty_sync(file->f_path.dentry->d_inode); >++#endif >+ } >+ FreeXid(xid); >+ return total_written; >+@@ -1017,7 +1205,9 @@ struct cifsFileInfo *find_writable_file( >+ >+ if (cifs_inode == NULL) { >+ cERROR(1, ("Null inode passed to cifs_writeable_file")); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 19) >+ dump_stack(); >++#endif >+ return NULL; >+ } >+ >+@@ -1030,21 +1220,24 @@ struct cifsFileInfo *find_writable_file( >+ (open_file->pfile->f_flags & O_WRONLY))) { >+ atomic_inc(&open_file->wrtPending); >+ read_unlock(&GlobalSMBSeslock); >+- if ((open_file->invalidHandle) && >+- (!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) { >++ if (open_file->invalidHandle) { >+ rc = cifs_reopen_file(open_file->pfile, FALSE); >+ /* if it fails, try another handle - might be */ >+ /* dangerous to hold up writepages with retry */ >+ if (rc) { >+- cFYI(1, >+- ("failed on reopen file in wp")); >++ cFYI(1, ("wp failed on reopen file")); >+ read_lock(&GlobalSMBSeslock); >+ /* can not use this handle, no write >+ pending on this one after all */ >+- atomic_dec >+- (&open_file->wrtPending); >++ atomic_dec(&open_file->wrtPending); >+ continue; >++ >++ } >+ } >++ if (open_file->closePend) { >++ read_lock(&GlobalSMBSeslock); >++ atomic_dec(&open_file->wrtPending); >++ continue; >+ } >+ return open_file; >+ } >+@@ -1113,6 +1306,7 @@ static int cifs_partialpagewrite(struct >+ return rc; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 14) >+ static int cifs_writepages(struct address_space *mapping, >+ struct writeback_control *wbc) >+ { >+@@ -1123,7 +1317,11 @@ static int cifs_writepages(struct addres >+ int done = 0; >+ pgoff_t end; >+ pgoff_t index; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ int range_whole = 0; >++#else >++ int is_range = 0; >++#endif /* 2.6.17 */ >+ struct kvec *iov; >+ int len; >+ int n_iov = 0; >+@@ -1170,6 +1368,7 @@ static int cifs_writepages(struct addres >+ xid = GetXid(); >+ >+ pagevec_init(&pvec, 0); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ if (wbc->range_cyclic) { >+ index = mapping->writeback_index; /* Start from prev offset */ >+ end = -1; >+@@ -1180,6 +1379,21 @@ static int cifs_writepages(struct addres >+ range_whole = 1; >+ scanned = 1; >+ } >++#else >++ end = -1; >++ if (wbc->sync_mode == WB_SYNC_NONE) >++ index = mapping->writeback_index; /* Start from prev offset */ >++ else { >++ index = 0; >++ scanned = 1; >++ } >++ if (wbc->start || wbc->end) { >++ index = wbc->start >> PAGE_CACHE_SHIFT; >++ end = wbc->end >> PAGE_CACHE_SHIFT; >++ is_range = 1; >++ scanned = 1; >++ } >++#endif /* 2.6.17 */ >+ retry: >+ while (!done && (index <= end) && >+ (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, >+@@ -1213,7 +1427,11 @@ retry: >+ break; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ if (!wbc->range_cyclic && page->index > end) { >++#else >++ if (unlikely(is_range) && (page->index > end)) { >++#endif /* 2.6.17 */ >+ done = 1; >+ unlock_page(page); >+ break; >+@@ -1325,15 +1543,24 @@ retry: >+ index = 0; >+ goto retry; >+ } >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) >++#else >++ if (!is_range) >++#endif /* 2.6.17 */ >+ mapping->writeback_index = index; >+ >+ FreeXid(xid); >+ kfree(iov); >+ return rc; >+ } >++#endif /* KERNEL_VERSION > 2.6.14 */ >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) >++static int cifs_writepage(struct page* page) >++#else >+ static int cifs_writepage(struct page *page, struct writeback_control *wbc) >++#endif >+ { >+ int rc = -EFAULT; >+ int xid; >+@@ -1415,7 +1642,11 @@ int cifs_fsync(struct file *file, struct >+ { >+ int xid; >+ int rc = 0; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ struct inode *inode = file->f_dentry->d_inode; >++#else >+ struct inode *inode = file->f_path.dentry->d_inode; >++#endif >+ >+ xid = GetXid(); >+ >+@@ -1461,9 +1692,17 @@ int cifs_fsync(struct file *file, struct >+ * As file closes, flush all cached write data for this inode checking >+ * for write behind errors. >+ */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ int cifs_flush(struct file *file, fl_owner_t id) >+-{ >++#else >++int cifs_flush(struct file *file) >++#endif /* 2.6.17 */ >++{ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ struct inode *inode = file->f_dentry->d_inode; >++#else >+ struct inode *inode = file->f_path.dentry->d_inode; >++#endif >+ int rc = 0; >+ >+ /* Rather than do the steps manually: >+@@ -1500,7 +1739,11 @@ ssize_t cifs_user_read(struct file *file >+ struct smb_com_read_rsp *pSMBr; >+ >+ xid = GetXid(); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >++#endif >+ pTcon = cifs_sb->tcon; >+ >+ if (file->private_data == NULL) { >+@@ -1581,7 +1824,11 @@ static ssize_t cifs_read(struct file *fi >+ int buf_type = CIFS_NO_BUFFER; >+ >+ xid = GetXid(); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >++#endif >+ pTcon = cifs_sb->tcon; >+ >+ if (file->private_data == NULL) { >+@@ -1637,7 +1884,11 @@ static ssize_t cifs_read(struct file *fi >+ >+ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) >+ { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ struct dentry *dentry = file->f_dentry; >++#else >+ struct dentry *dentry = file->f_path.dentry; >++#endif >+ int rc, xid; >+ >+ xid = GetXid(); >+@@ -1652,7 +1903,7 @@ int cifs_file_mmap(struct file *file, st >+ return rc; >+ } >+ >+- >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ static void cifs_copy_cache_pages(struct address_space *mapping, >+ struct list_head *pages, int bytes_read, char *data, >+ struct pagevec *plru_pvec) >+@@ -1723,7 +1974,11 @@ static int cifs_readpages(struct file *f >+ return -EBADF; >+ } >+ open_file = (struct cifsFileInfo *)file->private_data; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >++#endif >+ pTcon = cifs_sb->tcon; >+ >+ pagevec_init(&lru_pvec, 0); >+@@ -1795,7 +2050,9 @@ static int cifs_readpages(struct file *f >+ cFYI(1, ("Read error in readpages: %d", rc)); >+ break; >+ } else if (bytes_read > 0) { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19) >+ task_io_account_read(bytes_read); >++#endif >+ pSMBr = (struct smb_com_read_rsp *)smb_read_data; >+ cifs_copy_cache_pages(mapping, page_list, bytes_read, >+ smb_read_data + 4 /* RFC1001 hdr */ + >+@@ -1846,6 +2103,7 @@ static int cifs_readpages(struct file *f >+ FreeXid(xid); >+ return rc; >+ } >++#endif >+ >+ static int cifs_readpage_worker(struct file *file, struct page *page, >+ loff_t *poffset) >+@@ -1864,8 +2122,13 @@ static int cifs_readpage_worker(struct f >+ else >+ cFYI(1, ("Bytes read %d", rc)); >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ file->f_dentry->d_inode->i_atime = >++ current_fs_time(file->f_dentry->d_inode->i_sb); >++#else >+ file->f_path.dentry->d_inode->i_atime = >+ current_fs_time(file->f_path.dentry->d_inode->i_sb); >++#endif >+ >+ if (PAGE_CACHE_SIZE > rc) >+ memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc); >+@@ -1938,7 +2201,11 @@ int is_size_safe_to_change(struct cifsIn >+ /* This inode is open for write at least once */ >+ struct cifs_sb_info *cifs_sb; >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); >++#else >++ cifs_sb = CIFS_SB(open_file->pfile->f_dentry->d_inode->i_sb); >++#endif >+ if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) { >+ /* since no page cache to corrupt on directio >+ we can change size safely */ >+@@ -1980,7 +2247,14 @@ static int cifs_prepare_write(struct fil >+ * We don't need to read data beyond the end of the file. >+ * zero it, and set the page uptodate >+ */ >+- simple_prepare_write(file, page, from, to); >++ void *kaddr = kmap_atomic(page, KM_USER0); >++ >++ if (from) >++ memset(kaddr, 0, from); >++ if (to < PAGE_CACHE_SIZE) >++ memset(kaddr + to, 0, PAGE_CACHE_SIZE - to); >++ flush_dcache_page(page); >++ kunmap_atomic(kaddr, KM_USER0); >+ SetPageUptodate(page); >+ } else if ((file->f_flags & O_ACCMODE) != O_WRONLY) { >+ /* might as well read a page, it is fast enough */ >+@@ -2001,12 +2275,18 @@ static int cifs_prepare_write(struct fil >+ >+ const struct address_space_operations cifs_addr_ops = { >+ .readpage = cifs_readpage, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ .readpages = cifs_readpages, >++#endif >+ .writepage = cifs_writepage, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 14) >+ .writepages = cifs_writepages, >++#endif >+ .prepare_write = cifs_prepare_write, >+ .commit_write = cifs_commit_write, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ .set_page_dirty = __set_page_dirty_nobuffers, >++#endif >+ /* .sync_page = cifs_sync_page, */ >+ /* .direct_IO = */ >+ }; >+@@ -2019,10 +2299,14 @@ const struct address_space_operations ci >+ const struct address_space_operations cifs_addr_ops_smallbuf = { >+ .readpage = cifs_readpage, >+ .writepage = cifs_writepage, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 14) >+ .writepages = cifs_writepages, >++#endif >+ .prepare_write = cifs_prepare_write, >+ .commit_write = cifs_commit_write, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ .set_page_dirty = __set_page_dirty_nobuffers, >++#endif >+ /* .sync_page = cifs_sync_page, */ >+ /* .direct_IO = */ >+ }; >+diff -up linux-2.6.23.i386/fs/cifs/cifs_unicode.h.pre150c linux-2.6.23.i386/fs/cifs/cifs_unicode.h >+--- linux-2.6.23.i386/fs/cifs/cifs_unicode.h.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifs_unicode.h 2008-01-09 17:40:28.000000000 +0100 >+@@ -58,6 +58,15 @@ extern signed char UniLowerTable[512]; >+ extern struct UniCaseRange UniLowerRange[]; >+ #endif /* UNIUPR_NOLOWER */ >+ >++#ifndef __le16 >++#define __le16 __u16 >++#define __le32 __u32 >++#define __le64 __u64 >++#define __be16 __u16 >++#define __be32 __u32 >++#define __be64 __u64 >++#endif >++ >+ #ifdef __KERNEL__ >+ int cifs_strfromUCS_le(char *, const __le16 *, int, const struct nls_table *); >+ int cifs_strtoUCS(__le16 *, const char *, int, const struct nls_table *); >+diff -up linux-2.6.23.i386/fs/cifs/cifssmb.c.pre150c linux-2.6.23.i386/fs/cifs/cifssmb.c >+--- linux-2.6.23.i386/fs/cifs/cifssmb.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifssmb.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -30,7 +30,10 @@ >+ #include <linux/fs.h> >+ #include <linux/kernel.h> >+ #include <linux/vfs.h> >++#include <linux/version.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ #include <linux/posix_acl_xattr.h> >++#endif >+ #include <asm/uaccess.h> >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+@@ -94,10 +97,9 @@ static void mark_open_files_invalid(stru >+ write_lock(&GlobalSMBSeslock); >+ list_for_each_safe(tmp, tmp1, &pTcon->openFileList) { >+ open_file = list_entry(tmp, struct cifsFileInfo, tlist); >+- if (open_file) { >++ if (open_file) >+ open_file->invalidHandle = TRUE; >+ } >+- } >+ write_unlock(&GlobalSMBSeslock); >+ /* BB Add call to invalidate_inodes(sb) for all superblocks mounted >+ to this tcon */ >+@@ -132,13 +134,20 @@ small_smb_init(int smb_command, int wct, >+ /* Give Demultiplex thread up to 10 seconds to >+ reconnect, should be greater than cifs socket >+ timeout which is 7 seconds */ >+- while (tcon->ses->server->tcpStatus == >+- CifsNeedReconnect) { >++ while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >++ int timeout = 10 * HZ; >++ while((tcon->ses->server->tcpStatus != CifsGood) >++ && (timeout > 0)) { >++ timeout = interruptible_sleep_on_timeout( >++ &tcon->ses->server->response_q, >++ timeout); >++ } >++#else >+ wait_event_interruptible_timeout(tcon->ses->server->response_q, >+- (tcon->ses->server->tcpStatus == >+- CifsGood), 10 * HZ); >+- if (tcon->ses->server->tcpStatus == >+- CifsNeedReconnect) { >++ (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); >++#endif >++ if (tcon->ses->server->tcpStatus == CifsNeedReconnect) { >+ /* on "soft" mounts we wait once */ >+ if ((tcon->retry == FALSE) || >+ (tcon->ses->status == CifsExiting)) { >+@@ -278,11 +287,19 @@ smb_init(int smb_command, int wct, struc >+ /* Give Demultiplex thread up to 10 seconds to >+ reconnect, should be greater than cifs socket >+ timeout which is 7 seconds */ >+- while (tcon->ses->server->tcpStatus == >+- CifsNeedReconnect) { >++ while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >++ int timeout = 10 * HZ; >++ while((tcon->ses->server->tcpStatus != CifsGood) >++ && (timeout > 0)) { >++ timeout = interruptible_sleep_on_timeout >++ (&tcon->ses->server->response_q, >++ timeout); >++ } >++#else >+ wait_event_interruptible_timeout(tcon->ses->server->response_q, >+- (tcon->ses->server->tcpStatus == >+- CifsGood), 10 * HZ); >++ (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); >++#endif >+ if (tcon->ses->server->tcpStatus == >+ CifsNeedReconnect) { >+ /* on "soft" mounts we wait once */ >+@@ -513,7 +530,7 @@ CIFSSMBNegotiate(unsigned int xid, struc >+ (int)ts.tv_sec, (int)utc.tv_sec, >+ (int)(utc.tv_sec - ts.tv_sec))); >+ val = (int)(utc.tv_sec - ts.tv_sec); >+- seconds = val < 0 ? -val : val; >++ seconds = abs(val); >+ result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ; >+ remain = seconds % MIN_TZ_ADJ; >+ if (remain >= (MIN_TZ_ADJ / 2)) >+@@ -1193,9 +1210,9 @@ OldOpenRetry: >+ } >+ if (*pOplock & REQ_OPLOCK) >+ pSMB->OpenFlags = cpu_to_le16(REQ_OPLOCK); >+- else if (*pOplock & REQ_BATCHOPLOCK) { >++ else if (*pOplock & REQ_BATCHOPLOCK) >+ pSMB->OpenFlags = cpu_to_le16(REQ_BATCHOPLOCK); >+- } >++ >+ pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO); >+ /* BB fixme add conversion for access_flags to bits 0 - 2 of mode */ >+ /* 0 = read >+@@ -1310,9 +1327,8 @@ openRetry: >+ } >+ if (*pOplock & REQ_OPLOCK) >+ pSMB->OpenFlags = cpu_to_le32(REQ_OPLOCK); >+- else if (*pOplock & REQ_BATCHOPLOCK) { >++ else if (*pOplock & REQ_BATCHOPLOCK) >+ pSMB->OpenFlags = cpu_to_le32(REQ_BATCHOPLOCK); >+- } >+ pSMB->DesiredAccess = cpu_to_le32(access_flags); >+ pSMB->AllocationSize = 0; >+ /* set file as system file if special file such >+@@ -2615,7 +2631,7 @@ CIFSSMBQueryReparseLinkInfo(const int xi >+ reparse_buf->TargetNameOffset + >+ reparse_buf->TargetNameLen) > >+ end_of_smb) { >+- cFYI(1,("reparse buf goes beyond SMB")); >++ cFYI(1, ("reparse buf beyond SMB")); >+ rc = -EIO; >+ goto qreparse_out; >+ } >+@@ -2656,6 +2672,7 @@ qreparse_out: >+ return rc; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ #ifdef CONFIG_CIFS_POSIX >+ >+ /*Convert an Access Control Entry from wire format to local POSIX xattr format*/ >+@@ -3041,7 +3058,7 @@ GetExtAttrOut: >+ } >+ >+ #endif /* CONFIG_POSIX */ >+- >++#endif /* if version > 2.5 */ >+ >+ /* security id for everyone */ >+ static const struct cifs_sid sid_everyone = >+@@ -3177,7 +3194,11 @@ QInfRetry: >+ ts.tv_nsec = 0; >+ ts.tv_sec = time; >+ /* decode time fields */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ pFinfo->ChangeTime = cpu_to_le64(cifs_UnixTimeToNT(ts)); >++#else >++ pFinfo->ChangeTime = cpu_to_le64(cifs_UnixTimeToNT(time)); >++#endif >+ pFinfo->LastWriteTime = pFinfo->ChangeTime; >+ pFinfo->LastAccessTime = 0; >+ pFinfo->AllocationSize = >+@@ -3363,7 +3384,7 @@ UnixQPathInfoRetry: >+ rc = validate_t2((struct smb_t2_rsp *)pSMBr); >+ >+ if (rc || (pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO))) { >+- rc = -EIO; /* bad smb */ >++ rc = --EOPNOTSUPP; /* bad smb */ >+ } else { >+ __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); >+ memcpy((char *) pFindData, >+@@ -3883,12 +3904,10 @@ getDFSRetry: >+ pSMB->hdr.Mid = GetNextMid(ses->server); >+ pSMB->hdr.Tid = ses->ipc_tid; >+ pSMB->hdr.Uid = ses->Suid; >+- if (ses->capabilities & CAP_STATUS32) { >++ if (ses->capabilities & CAP_STATUS32) >+ pSMB->hdr.Flags2 |= SMBFLG2_ERR_STATUS; >+- } >+- if (ses->capabilities & CAP_DFS) { >++ if (ses->capabilities & CAP_DFS) >+ pSMB->hdr.Flags2 |= SMBFLG2_DFS; >+- } >+ >+ if (ses->capabilities & CAP_UNICODE) { >+ pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; >+@@ -4044,7 +4063,11 @@ GetDFSRefExit: >+ >+ /* Query File System Info such as free space to old servers such as Win 9x */ >+ int >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, struct kstatfs *FSData) >++#else >++SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, struct statfs *FSData) >++#endif >+ { >+ /* level 0x01 SMB_QUERY_FILE_SYSTEM_INFO */ >+ TRANSACTION2_QFSI_REQ *pSMB = NULL; >+@@ -4128,7 +4151,11 @@ oldQFSInfoRetry: >+ } >+ >+ int >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, struct kstatfs *FSData) >++#else >++CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, struct statfs *FSData) >++#endif >+ { >+ /* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ >+ TRANSACTION2_QFSI_REQ *pSMB = NULL; >+@@ -4490,7 +4517,11 @@ SETFSUnixRetry: >+ >+ int >+ CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct kstatfs *FSData) >++#else >++ struct statfs *FSData) >++#endif >+ { >+ /* level 0x201 SMB_QUERY_CIFS_POSIX_INFO */ >+ TRANSACTION2_QFSI_REQ *pSMB = NULL; >+diff -up linux-2.6.23.i386/fs/cifs/xattr.c.pre150c linux-2.6.23.i386/fs/cifs/xattr.c >+--- linux-2.6.23.i386/fs/cifs/xattr.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/xattr.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -20,7 +20,10 @@ >+ */ >+ >+ #include <linux/fs.h> >++#include <linux/version.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ #include <linux/posix_acl_xattr.h> >++#endif >+ #include "cifsfs.h" >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+diff -up linux-2.6.23.i386/fs/cifs/asn1.c.pre150c linux-2.6.23.i386/fs/cifs/asn1.c >+--- linux-2.6.23.i386/fs/cifs/asn1.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/asn1.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -26,6 +26,9 @@ >+ #include "cifsglob.h" >+ #include "cifs_debug.h" >+ #include "cifsproto.h" >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) >++#include <linux/config.h> >++#endif >+ >+ /***************************************************************************** >+ * >+@@ -386,9 +389,8 @@ asn1_oid_decode(struct asn1_ctx *ctx, >+ >+ size = eoc - ctx->pointer + 1; >+ *oid = kmalloc(size * sizeof (unsigned long), GFP_ATOMIC); >+- if (*oid == NULL) { >++ if (*oid == NULL) >+ return 0; >+- } >+ >+ optr = *oid; >+ >+@@ -581,8 +583,7 @@ decode_negTokenInit(unsigned char *secur >+ return 0; >+ } else if ((cls != ASN1_UNI) || (con != ASN1_CON) >+ || (tag != ASN1_SEQ)) { >+- cFYI(1, >+- ("Exit 6 cls = %d con = %d tag = %d end = %p (%d)", >++ cFYI(1, ("cls = %d con = %d tag = %d end = %p (%d)", >+ cls, con, tag, end, *end)); >+ } >+ >+diff -up linux-2.6.23.i386/fs/cifs/dir.c.pre150c linux-2.6.23.i386/fs/cifs/dir.c >+--- linux-2.6.23.i386/fs/cifs/dir.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/dir.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -23,13 +23,19 @@ >+ #include <linux/fs.h> >+ #include <linux/stat.h> >+ #include <linux/slab.h> >++#include <linux/version.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ #include <linux/namei.h> >++#endif >+ #include "cifsfs.h" >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+ #include "cifsproto.h" >+ #include "cifs_debug.h" >+ #include "cifs_fs_sb.h" >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) >++#include <linux/ctype.h> >++#endif >+ >+ static void >+ renew_parental_timestamps(struct dentry *direntry) >+@@ -124,8 +130,12 @@ BB remove above eight lines BB */ >+ /* Inode operations in similar order to how they appear in Linux file fs.h */ >+ >+ int >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ cifs_create(struct inode *inode, struct dentry *direntry, int mode, >+ struct nameidata *nd) >++#else >++cifs_create(struct inode *inode, struct dentry *direntry, int mode) >++#endif >+ { >+ int rc = -ENOENT; >+ int xid; >+@@ -137,10 +147,12 @@ cifs_create(struct inode *inode, struct >+ char *full_path = NULL; >+ FILE_ALL_INFO *buf = NULL; >+ struct inode *newinode = NULL; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct cifsFileInfo *pCifsFile = NULL; >+ struct cifsInodeInfo *pCifsInode; >+- int disposition = FILE_OVERWRITE_IF; >+ int write_only = FALSE; >++#endif >++ int disposition = FILE_OVERWRITE_IF; >+ >+ xid = GetXid(); >+ >+@@ -153,8 +165,13 @@ cifs_create(struct inode *inode, struct >+ return -ENOMEM; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ if (nd && (nd->flags & LOOKUP_OPEN)) { >++#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,5) /* SUSE included Lustre patch */ >++ int oflags = nd->intent.it_flags; >++#else >+ int oflags = nd->intent.open.flags; >++#endif >+ >+ desiredAccess = 0; >+ if (oflags & FMODE_READ) >+@@ -180,6 +197,9 @@ cifs_create(struct inode *inode, struct >+ ACLs */ >+ if (oplockEnabled) >+ oplock = REQ_OPLOCK; >++#else >++ desiredAccess = GENERIC_WRITE; >++#endif >+ >+ buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); >+ if (buf == NULL) { >+@@ -263,6 +283,7 @@ cifs_create(struct inode *inode, struct >+ direntry->d_op = &cifs_dentry_ops; >+ d_instantiate(direntry, newinode); >+ } >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ if ((nd == NULL /* nfsd case - nfs srv does not set nd */) || >+ ((nd->flags & LOOKUP_OPEN) == FALSE)) { >+ /* mknod case - do not leave file open */ >+@@ -279,7 +300,11 @@ cifs_create(struct inode *inode, struct >+ pCifsFile->invalidHandle = FALSE; >+ pCifsFile->closePend = FALSE; >+ init_MUTEX(&pCifsFile->fh_sem); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ mutex_init(&pCifsFile->lock_mutex); >++#else >++ init_MUTEX(&pCifsFile->lock_mutex); >++#endif >+ INIT_LIST_HEAD(&pCifsFile->llist); >+ atomic_set(&pCifsFile->wrtPending, 0); >+ >+@@ -309,14 +334,22 @@ cifs_create(struct inode *inode, struct >+ } >+ } >+ cifs_create_out: >++#else /* 2.4 does not pass open flags so must reopen on cifs_open */ >++ CIFSSMBClose(xid, pTcon, fileHandle); >++ } >++#endif >+ kfree(buf); >+ kfree(full_path); >+ FreeXid(xid); >+ return rc; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, >+ dev_t device_number) >++#else >++int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, int device_number) >++#endif >+ { >+ int rc = -EPERM; >+ int xid; >+@@ -325,8 +358,10 @@ int cifs_mknod(struct inode *inode, stru >+ char *full_path = NULL; >+ struct inode *newinode = NULL; >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ if (!old_valid_dev(device_number)) >+ return -EINVAL; >++#endif >+ >+ xid = GetXid(); >+ >+@@ -397,7 +432,7 @@ int cifs_mknod(struct inode *inode, stru >+ /* BB Do not bother to decode buf since no >+ local inode yet to put timestamps in, >+ but we can reuse it safely */ >+- int bytes_written; >++ unsigned int bytes_written; >+ struct win_dev *pdev; >+ pdev = (struct win_dev *)buf; >+ if (S_ISCHR(mode)) { >+@@ -436,10 +471,14 @@ int cifs_mknod(struct inode *inode, stru >+ return rc; >+ } >+ >+- >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct dentry * >+ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, >+ struct nameidata *nd) >++#else >++struct dentry * >++cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry) >++#endif >+ { >+ int xid; >+ int rc = 0; /* to get around spurious gcc warning, set to zero here */ >+@@ -531,8 +570,13 @@ cifs_lookup(struct inode *parent_dir_ino >+ return ERR_PTR(rc); >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ static int >+ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd) >++#else >++static int >++cifs_d_revalidate(struct dentry *direntry, int flags) >++#endif >+ { >+ int isValid = 1; >+ >+@@ -567,6 +611,10 @@ struct dentry_operations cifs_dentry_ops >+ /* d_delete: cifs_d_delete, */ /* not needed except for debugging */ >+ }; >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) >++#define nls_tolower(cp, name) tolower(name) >++#define nls_strnicmp(cp, name1, name2, len) strnicmp(name1, name2, len) >++#endif >+ static int cifs_ci_hash(struct dentry *dentry, struct qstr *q) >+ { >+ struct nls_table *codepage = CIFS_SB(dentry->d_inode->i_sb)->local_nls; >+diff -up linux-2.6.23.i386/fs/cifs/cifs_debug.c.pre150c linux-2.6.23.i386/fs/cifs/cifs_debug.c >+--- linux-2.6.23.i386/fs/cifs/cifs_debug.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifs_debug.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -209,13 +209,16 @@ cifs_debug_data_read(char *buf, char **b >+ i++; >+ tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); >+ dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); >+- length = >+- sprintf(buf, >+- "\n%d) %s Uses: %d Type: %s DevInfo: 0x%x " >+- "Attributes: 0x%x\nPathComponentMax: %d Status: %d", >+- i, tcon->treeName, >+- atomic_read(&tcon->useCount), >+- tcon->nativeFileSystem, >++ length = sprintf(buf, "\n%d) %s Uses: %d ", i, >++ tcon->treeName, atomic_read(&tcon->useCount)); >++ buf += length; >++ if (tcon->nativeFileSystem) { >++ length = sprintf(buf, "Type: %s ", >++ tcon->nativeFileSystem); >++ buf += length; >++ } >++ length = sprintf(buf, "DevInfo: 0x%x Attributes: 0x%x" >++ "\nPathComponentMax: %d Status: %d", >+ le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), >+ le32_to_cpu(tcon->fsAttrInfo.Attributes), >+ le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), >+diff -up linux-2.6.23.i386/fs/cifs/sess.c.pre150c linux-2.6.23.i386/fs/cifs/sess.c >+--- linux-2.6.23.i386/fs/cifs/sess.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/sess.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -21,6 +21,7 @@ >+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ */ >+ >++#include <linux/fs.h> >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+ #include "cifsproto.h" >+@@ -67,9 +68,8 @@ static __u32 cifs_ssetup_hdr(struct cifs >+ pSMB->req.hdr.Flags2 |= SMBFLG2_DFS; >+ capabilities |= CAP_DFS; >+ } >+- if (ses->capabilities & CAP_UNIX) { >++ if (ses->capabilities & CAP_UNIX) >+ capabilities |= CAP_UNIX; >+- } >+ >+ /* BB check whether to init vcnum BB */ >+ return capabilities; >+@@ -117,8 +117,13 @@ static void unicode_ssetup_strings(char >+ bytes_ret = cifs_strtoUCS((__le16 *)bcc_ptr, "Linux version ", 32, >+ nls_cp); >+ bcc_ptr += 2 * bytes_ret; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, init_utsname()->release, >+ 32, nls_cp); >++#else >++ bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release, >++ 32, nls_cp); >++#endif >+ bcc_ptr += 2 * bytes_ret; >+ bcc_ptr += 2; /* trailing null */ >+ >+@@ -162,9 +167,13 @@ static void ascii_ssetup_strings(char ** >+ >+ strcpy(bcc_ptr, "Linux version "); >+ bcc_ptr += strlen("Linux version "); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ strcpy(bcc_ptr, init_utsname()->release); >+ bcc_ptr += strlen(init_utsname()->release) + 1; >+- >++#else >++ strcpy(bcc_ptr, system_utsname.release); >++ bcc_ptr += strlen(system_utsname.release) + 1; >++#endif >+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); >+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; >+ >+@@ -203,14 +212,11 @@ static int decode_unicode_ssetup(char ** >+ if (len >= words_left) >+ return rc; >+ >+- if (ses->serverOS) >+ kfree(ses->serverOS); >+ /* UTF-8 string will not grow more than four times as big as UCS-16 */ >+ ses->serverOS = kzalloc(4 * len, GFP_KERNEL); >+- if (ses->serverOS != NULL) { >+- cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, >+- nls_cp); >+- } >++ if (ses->serverOS != NULL) >++ cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, nls_cp); >+ data += 2 * (len + 1); >+ words_left -= len + 1; >+ >+@@ -220,7 +226,6 @@ static int decode_unicode_ssetup(char ** >+ if (len >= words_left) >+ return rc; >+ >+- if (ses->serverNOS) >+ kfree(ses->serverNOS); >+ ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */ >+ if (ses->serverNOS != NULL) { >+@@ -240,7 +245,6 @@ static int decode_unicode_ssetup(char ** >+ if (len > words_left) >+ return rc; >+ >+- if (ses->serverDomain) >+ kfree(ses->serverDomain); >+ ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */ >+ if (ses->serverDomain != NULL) { >+@@ -271,7 +275,6 @@ static int decode_ascii_ssetup(char **pb >+ if (len >= bleft) >+ return rc; >+ >+- if (ses->serverOS) >+ kfree(ses->serverOS); >+ >+ ses->serverOS = kzalloc(len + 1, GFP_KERNEL); >+@@ -289,7 +292,6 @@ static int decode_ascii_ssetup(char **pb >+ if (len >= bleft) >+ return rc; >+ >+- if (ses->serverNOS) >+ kfree(ses->serverNOS); >+ >+ ses->serverNOS = kzalloc(len + 1, GFP_KERNEL); >+@@ -479,7 +481,8 @@ CIFS_SessSetup(unsigned int xid, struct >+ if (ses->capabilities & CAP_UNICODE) { >+ if (iov[0].iov_len % 2) { >+ *bcc_ptr = 0; >+- } bcc_ptr++; >++ bcc_ptr++; >++ } >+ unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); >+ } else >+ ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); >+diff -up linux-2.6.23.i386/fs/cifs/cifsglob.h.pre150c linux-2.6.23.i386/fs/cifs/cifsglob.h >+--- linux-2.6.23.i386/fs/cifs/cifsglob.h.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifsglob.h 2008-01-09 17:40:28.000000000 +0100 >+@@ -18,6 +18,7 @@ >+ */ >+ #include <linux/in.h> >+ #include <linux/in6.h> >++#include <linux/version.h> >+ #include "cifs_fs_sb.h" >+ /* >+ * The sizes of various internal tables and strings >+@@ -68,6 +69,14 @@ >+ #define XATTR_DOS_ATTRIB "user.DOSATTRIB" >+ #endif >+ >++#ifndef SLAB_NOFS >++#define SLAB_NOFS GFP_NOFS >++#endif >++ >++#ifndef SLAB_KERNEL >++#define SLAB_KERNEL GFP_KERNEL >++#endif >++ >+ /* >+ * This information is kept on every Server we know about. >+ * >+@@ -325,7 +334,11 @@ struct cifsFileInfo { >+ /* lock scope id (0 if none) */ >+ struct file *pfile; /* needed for writepage */ >+ struct inode *pInode; /* needed for oplock break */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ struct mutex lock_mutex; >++#else >++ struct semaphore lock_mutex; >++#endif >+ struct list_head llist; /* list of byte range locks we have. */ >+ unsigned closePend:1; /* file is marked to close */ >+ unsigned invalidHandle:1; /* file closed via session abend */ >+@@ -350,9 +363,12 @@ struct cifsInodeInfo { >+ unsigned clientCanCacheRead:1; /* read oplock */ >+ unsigned clientCanCacheAll:1; /* read and writebehind oplock */ >+ unsigned oplockPending:1; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct inode vfs_inode; >++#endif >+ }; >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ static inline struct cifsInodeInfo * >+ CIFS_I(struct inode *inode) >+ { >+@@ -364,6 +380,21 @@ CIFS_SB(struct super_block *sb) >+ { >+ return sb->s_fs_info; >+ } >++#else /* 2.4 kernel case */ >++static inline struct cifsInodeInfo * >++CIFS_I(struct inode *inode) >++{ >++ return (struct cifsInodeInfo *)&(inode->u); >++} >++ >++static inline struct cifs_sb_info * >++CIFS_SB(struct super_block *sb) >++{ >++ return (struct cifs_sb_info *) &(sb->u); >++} >++ >++extern struct inode * get_cifs_inode(struct super_block * sb); >++#endif >+ >+ static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb) >+ { >+diff -up linux-2.6.23.i386/fs/cifs/cifsfs.c.pre150c linux-2.6.23.i386/fs/cifs/cifsfs.c >+--- linux-2.6.23.i386/fs/cifs/cifsfs.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifsfs.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -34,7 +34,6 @@ >+ #include <linux/mempool.h> >+ #include <linux/delay.h> >+ #include <linux/kthread.h> >+-#include <linux/freezer.h> >+ #include "cifsfs.h" >+ #include "cifspdu.h" >+ #define DECLARE_GLOBALS_HERE >+@@ -43,6 +42,12 @@ >+ #include "cifs_debug.h" >+ #include "cifs_fs_sb.h" >+ #include <linux/mm.h> >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) >++#include <linux/moduleparam.h> >++#endif /* 2.6.9 */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19) >++#include <linux/freezer.h> >++#endif /* 2.6.19 */ >+ #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ >+ >+ #ifdef CONFIG_CIFS_QUOTA >+@@ -184,10 +189,34 @@ cifs_put_super(struct super_block *sb) >+ return; >+ } >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15) >++void * kzalloc(size_t size, unsigned flgs) >++{ >++ void * buf; >++ buf = kmalloc(size, flgs); >++ if(buf != NULL) >++ memset(buf, 0, size); >++ return buf; >++} >++#endif >++ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ static int >+ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) >+ { >+ struct super_block *sb = dentry->d_sb; >++#else >++static inline mempool_t * >++mempool_create_slab_pool(int min_nr, struct kmem_cache *kc) >++{ >++ return mempool_create(min_nr, mempool_alloc_slab, mempool_free_slab, >++ (void *) kc); >++} >++ >++static int >++cifs_statfs(struct super_block *sb, struct kstatfs *buf) >++{ >++#endif >+ int xid; >+ int rc = -EOPNOTSUPP; >+ struct cifs_sb_info *cifs_sb; >+@@ -240,13 +269,17 @@ static int cifs_permission(struct inode >+ >+ cifs_sb = CIFS_SB(inode->i_sb); >+ >+- if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) { >++ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) >+ return 0; >+- } else /* file mode might have been restricted at mount time >++ else /* file mode might have been restricted at mount time >+ on the client (above and beyond ACL on servers) for >+ servers which do not support setting and viewing mode bits, >+ so allowing client to check permissions is useful */ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) >++ return vfs_permission(inode, mask); >++#else >+ return generic_permission(inode, mask, NULL); >++#endif >+ } >+ >+ static struct kmem_cache *cifs_inode_cachep; >+@@ -273,6 +306,9 @@ cifs_alloc_inode(struct super_block *sb) >+ file data or metadata */ >+ cifs_inode->clientCanCacheRead = FALSE; >+ cifs_inode->clientCanCacheAll = FALSE; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) >++ cifs_inode->vfs_inode.i_blksize = CIFS_MAX_MSGSIZE; >++#endif >+ cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ >+ >+ /* Can not set i_flags here - they get immediately overwritten >+@@ -346,7 +382,7 @@ int cifs_xquota_set(struct super_block * >+ if (pTcon) { >+ cFYI(1, ("set type: 0x%x id: %d", quota_type, qid)); >+ } else { >+- return -EIO; >++ rc = -EIO; >+ } >+ >+ FreeXid(xid); >+@@ -431,14 +467,22 @@ static struct quotactl_ops cifs_quotactl >+ }; >+ #endif >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 16) >+ static void cifs_umount_begin(struct vfsmount *vfsmnt, int flags) >++#else >++static void cifs_umount_begin(struct super_block * sblock) >++#endif >+ { >+ struct cifs_sb_info *cifs_sb; >+ struct cifsTconInfo *tcon; >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 16) >+ if (!(flags & MNT_FORCE)) >+ return; >+ cifs_sb = CIFS_SB(vfsmnt->mnt_sb); >++#else >++ cifs_sb = CIFS_SB(sblock); >++#endif >+ if (cifs_sb == NULL) >+ return; >+ >+@@ -467,12 +511,14 @@ static void cifs_umount_begin(struct vfs >+ } >+ >+ #ifdef CONFIG_CIFS_STATS2 >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt) >+ { >+ /* BB FIXME */ >+ return 0; >+ } >+ #endif >++#endif >+ >+ static int cifs_remount(struct super_block *sb, int *flags, char *data) >+ { >+@@ -495,13 +541,25 @@ static const struct super_operations cif >+ .umount_begin = cifs_umount_begin, >+ .remount_fs = cifs_remount, >+ #ifdef CONFIG_CIFS_STATS2 >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ .show_stats = cifs_show_stats, >+ #endif >++#endif >+ }; >+ >++#ifndef MS_SILENT >++#define MS_SILENT MS_VERBOSE >++#endif >++ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ static int >+ cifs_get_sb(struct file_system_type *fs_type, >+ int flags, const char *dev_name, void *data, struct vfsmount *mnt) >++#else >++static struct super_block * >++cifs_get_sb(struct file_system_type *fs_type, >++ int flags, const char *dev_name, void *data) >++#endif >+ { >+ int rc; >+ struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL); >+@@ -509,7 +567,11 @@ cifs_get_sb(struct file_system_type *fs_ >+ cFYI(1, ("Devname: %s flags: %d ", dev_name, flags)); >+ >+ if (IS_ERR(sb)) >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ return PTR_ERR(sb); >++#else >++ return sb; >++#endif >+ >+ sb->s_flags = flags; >+ >+@@ -517,12 +579,21 @@ cifs_get_sb(struct file_system_type *fs_ >+ if (rc) { >+ up_write(&sb->s_umount); >+ deactivate_super(sb); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ return rc; >++#else >++ return ERR_PTR(rc); >++#endif >+ } >+ sb->s_flags |= MS_ACTIVE; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) >+ return simple_set_mnt(mnt, sb); >++#else >++ return sb; >++#endif >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, >+ unsigned long nr_segs, loff_t pos) >+ { >+@@ -530,6 +601,27 @@ static ssize_t cifs_file_aio_write(struc >+ ssize_t written; >+ >+ written = generic_file_aio_write(iocb, iov, nr_segs, pos); >++#else >++static ssize_t cifs_file_writev(struct file *file, const struct iovec *iov, >++ unsigned long nr_segs, loff_t *ppos) >++{ >++ struct inode *inode = file->f_dentry->d_inode; >++ ssize_t written; >++ >++ written = generic_file_writev(file, iov, nr_segs, ppos); >++ if (!CIFS_I(inode)->clientCanCacheAll) >++ filemap_fdatawrite(inode->i_mapping); >++ return written; >++} >++ >++static ssize_t cifs_file_aio_write(struct kiocb *iocb, const char __user *buf, >++ size_t count, loff_t pos) >++{ >++ struct inode *inode = iocb->ki_filp->f_dentry->d_inode; >++ ssize_t written; >++ >++ written = generic_file_aio_write(iocb, buf, count, pos); >++#endif >+ if (!CIFS_I(inode)->clientCanCacheAll) >+ filemap_fdatawrite(inode->i_mapping); >+ return written; >+@@ -538,15 +630,21 @@ static ssize_t cifs_file_aio_write(struc >+ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) >+ { >+ /* origin == SEEK_END => we must revalidate the cached file length */ >+- if (origin == SEEK_END) { >++ if (origin == 2) { >+ int retval; >+ >+ /* some applications poll for the file length in this strange >+ way so we must seek to end on non-oplocked files by >+ setting the revalidate time to zero */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19) >+ CIFS_I(file->f_path.dentry->d_inode)->time = 0; >+ >+ retval = cifs_revalidate(file->f_path.dentry); >++#else >++ if(file->f_dentry->d_inode) >++ CIFS_I(file->f_dentry->d_inode)->time = 0; >++ retval = cifs_revalidate(file->f_dentry); >++#endif >+ if (retval < 0) >+ return (loff_t)retval; >+ } >+@@ -597,9 +695,13 @@ const struct inode_operations cifs_file_ >+ }; >+ >+ const struct inode_operations cifs_symlink_inode_ops = { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) >++ .readlink = cifs_readlink, >++#else >+ .readlink = generic_readlink, >+- .follow_link = cifs_follow_link, >+ .put_link = cifs_put_link, >++#endif >++ .follow_link = cifs_follow_link, >+ .permission = cifs_permission, >+ /* BB add the following two eventually */ >+ /* revalidate: cifs_revalidate, >+@@ -615,6 +717,10 @@ const struct inode_operations cifs_symli >+ const struct file_operations cifs_file_ops = { >+ .read = do_sync_read, >+ .write = do_sync_write, >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) >++ .readv = generic_file_readv, >++ .writev = cifs_file_writev, >++#endif >+ .aio_read = generic_file_aio_read, >+ .aio_write = cifs_file_aio_write, >+ .open = cifs_open, >+@@ -623,7 +729,11 @@ const struct file_operations cifs_file_o >+ .fsync = cifs_fsync, >+ .flush = cifs_flush, >+ .mmap = cifs_file_mmap, >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) >++ .sendfile = generic_file_sendfile, >++#else >+ .splice_read = generic_file_splice_read, >++#endif >+ .llseek = cifs_llseek, >+ #ifdef CONFIG_CIFS_POSIX >+ .ioctl = cifs_ioctl, >+@@ -644,7 +754,11 @@ const struct file_operations cifs_file_d >+ .lock = cifs_lock, >+ .fsync = cifs_fsync, >+ .flush = cifs_flush, >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) >++ .sendfile = generic_file_sendfile, /* BB removeme BB */ >++#else >+ .splice_read = generic_file_splice_read, >++#endif >+ #ifdef CONFIG_CIFS_POSIX >+ .ioctl = cifs_ioctl, >+ #endif /* CONFIG_CIFS_POSIX */ >+@@ -656,6 +770,10 @@ const struct file_operations cifs_file_d >+ const struct file_operations cifs_file_nobrl_ops = { >+ .read = do_sync_read, >+ .write = do_sync_write, >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) >++ .readv = generic_file_readv, >++ .writev = cifs_file_writev, >++#endif >+ .aio_read = generic_file_aio_read, >+ .aio_write = cifs_file_aio_write, >+ .open = cifs_open, >+@@ -663,7 +781,11 @@ const struct file_operations cifs_file_n >+ .fsync = cifs_fsync, >+ .flush = cifs_flush, >+ .mmap = cifs_file_mmap, >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) >++ .sendfile = generic_file_sendfile, >++#else >+ .splice_read = generic_file_splice_read, >++#endif >+ .llseek = cifs_llseek, >+ #ifdef CONFIG_CIFS_POSIX >+ .ioctl = cifs_ioctl, >+@@ -683,7 +805,11 @@ const struct file_operations cifs_file_d >+ .release = cifs_close, >+ .fsync = cifs_fsync, >+ .flush = cifs_flush, >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) >++ .sendfile = generic_file_sendfile, /* BB removeme BB */ >++#else >+ .splice_read = generic_file_splice_read, >++#endif >+ #ifdef CONFIG_CIFS_POSIX >+ .ioctl = cifs_ioctl, >+ #endif /* CONFIG_CIFS_POSIX */ >+@@ -703,6 +829,10 @@ const struct file_operations cifs_dir_op >+ .ioctl = cifs_ioctl, >+ }; >+ >++#ifndef SLAB_MEM_SPREAD >++#define SLAB_MEM_SPREAD 0 >++#endif >++ >+ static void >+ cifs_init_once(void *inode, struct kmem_cache *cachep, unsigned long flags) >+ { >+@@ -719,7 +849,11 @@ cifs_init_inodecache(void) >+ sizeof (struct cifsInodeInfo), >+ 0, (SLAB_RECLAIM_ACCOUNT| >+ SLAB_MEM_SPREAD), >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >+ cifs_init_once); >++#else >++ cifs_init_once, NULL); >++#endif >+ if (cifs_inode_cachep == NULL) >+ return -ENOMEM; >+ >+@@ -748,7 +882,11 @@ cifs_init_request_bufs(void) >+ cifs_req_cachep = kmem_cache_create("cifs_request", >+ CIFSMaxBufSize + >+ MAX_CIFS_HDR_SIZE, 0, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >+ SLAB_HWCACHE_ALIGN, NULL); >++#else >++ SLAB_HWCACHE_ALIGN, NULL, NULL); >++#endif >+ if (cifs_req_cachep == NULL) >+ return -ENOMEM; >+ >+@@ -776,7 +914,11 @@ cifs_init_request_bufs(void) >+ alloc of large cifs buffers even when page debugging is on */ >+ cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq", >+ MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >+ NULL); >++#else >++ NULL, NULL); >++#endif >+ if (cifs_sm_req_cachep == NULL) { >+ mempool_destroy(cifs_req_poolp); >+ kmem_cache_destroy(cifs_req_cachep); >+@@ -817,7 +959,11 @@ cifs_init_mids(void) >+ { >+ cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids", >+ sizeof (struct mid_q_entry), 0, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >+ SLAB_HWCACHE_ALIGN, NULL); >++#else >++ SLAB_HWCACHE_ALIGN, NULL, NULL); >++#endif >+ if (cifs_mid_cachep == NULL) >+ return -ENOMEM; >+ >+@@ -830,7 +976,11 @@ cifs_init_mids(void) >+ >+ cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs", >+ sizeof (struct oplock_q_entry), 0, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >+ SLAB_HWCACHE_ALIGN, NULL); >++#else >++ SLAB_HWCACHE_ALIGN, NULL, NULL); >++#endif >+ if (cifs_oplock_cachep == NULL) { >+ mempool_destroy(cifs_mid_poolp); >+ kmem_cache_destroy(cifs_mid_cachep); >+@@ -856,10 +1006,14 @@ static int cifs_oplock_thread(void *dumm >+ __u16 netfid; >+ int rc; >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >+ set_freezable(); >++#endif >+ do { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12) >+ if (try_to_freeze()) >+ continue; >++#endif >+ >+ spin_lock(&GlobalMid_Lock); >+ if (list_empty(&GlobalOplock_Q)) { >+@@ -882,7 +1036,8 @@ static int cifs_oplock_thread(void *dumm >+ the call */ >+ /* mutex_lock(&inode->i_mutex);*/ >+ if (S_ISREG(inode->i_mode)) { >+- rc = filemap_fdatawrite(inode->i_mapping); >++ rc = >++ filemap_fdatawrite(inode->i_mapping); >+ if (CIFS_I(inode)->clientCanCacheRead >+ == 0) { >+ filemap_fdatawait(inode->i_mapping); >+@@ -907,8 +1062,7 @@ static int cifs_oplock_thread(void *dumm >+ 0 /* len */ , 0 /* offset */, 0, >+ 0, LOCKING_ANDX_OPLOCK_RELEASE, >+ 0 /* wait flag */); >+- cFYI(1, >+- ("Oplock release rc = %d ", rc)); >++ cFYI(1, ("Oplock release rc = %d", rc)); >+ } >+ } else >+ spin_unlock(&GlobalMid_Lock); >+@@ -926,8 +1080,10 @@ static int cifs_dnotify_thread(void *dum >+ struct cifsSesInfo *ses; >+ >+ do { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12) >+ if (try_to_freeze()) >+ continue; >++#endif >+ set_current_state(TASK_INTERRUPTIBLE); >+ schedule_timeout(15*HZ); >+ read_lock(&GlobalSMBSeslock); >+diff -up linux-2.6.23.i386/fs/cifs/netmisc.c.pre150c linux-2.6.23.i386/fs/cifs/netmisc.c >+--- linux-2.6.23.i386/fs/cifs/netmisc.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/netmisc.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -132,6 +132,7 @@ static const struct smb_to_posix_error m >+ int >+ cifs_inet_pton(int address_family, char *cp, void *dst) >+ { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19) >+ int ret = 0; >+ >+ /* calculate length by finding first slash or NULL */ >+@@ -148,6 +149,66 @@ cifs_inet_pton(int address_family, char >+ if (ret > 0) >+ ret = 1; >+ return ret; >++#else /* pre-2.6.20 */ >++ int value; >++ int digit; >++ int i; >++ char temp; >++ char bytes[4]; >++ char *end = bytes; >++ static const int addr_class_max[4] = >++ { 0xffffffff, 0xffffff, 0xffff, 0xff }; >++ >++ if(address_family != AF_INET) >++ return -EAFNOSUPPORT; >++ >++ for (i = 0; i < 4; i++) { >++ bytes[i] = 0; >++ } >++ >++ temp = *cp; >++ >++ while (TRUE) { >++ if (!isdigit(temp)) >++ return 0; >++ >++ value = 0; >++ digit = 0; >++ for (;;) { >++ if (isascii(temp) && isdigit(temp)) { >++ value = (value * 10) + temp - '0'; >++ temp = *++cp; >++ digit = 1; >++ } else >++ break; >++ } >++ >++ if (temp == '.') { >++ if ((end > bytes + 2) || (value > 255)) >++ return 0; >++ *end++ = value; >++ temp = *++cp; >++ } else if (temp == ':') { >++ cFYI(1,("IPv6 addresses not supported for CIFS mounts yet")); >++ return -1; >++ } else >++ break; >++ } >++ >++ /* check for last characters */ >++ if (temp != '\0' && (!isascii(temp) || !isspace(temp))) >++ if (temp != '\\') { >++ if (temp != '/') >++ return 0; >++ else >++ (*cp = '\\'); /* switch the slash the expected way */ >++ } >++ if (value > addr_class_max[end - bytes]) >++ return 0; >++ >++ *((__be32 *)dst) = *((__be32 *) bytes) | htonl(value); >++ return 1; /* success */ >++#endif >+ } >+ >+ /***************************************************************************** >+@@ -848,6 +909,16 @@ smbCalcSize_LE(struct smb_hdr *ptr) >+ * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units) >+ * into Unix UTC (based 1970-01-01, in seconds). >+ */ >++ >++static int total_days_of_prev_months[] = >++{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; >++ >++__le64 cnvrtDosCifsTm(__u16 date, __u16 time) >++{ >++ return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time))); >++} >++ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) >+ struct timespec >+ cifs_NTtimeToUnix(u64 ntutc) >+ { >+@@ -871,14 +942,6 @@ cifs_UnixTimeToNT(struct timespec t) >+ return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET; >+ } >+ >+-static int total_days_of_prev_months[] = >+-{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; >+- >+- >+-__le64 cnvrtDosCifsTm(__u16 date, __u16 time) >+-{ >+- return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time))); >+-} >+ >+ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time) >+ { >+@@ -928,3 +991,80 @@ struct timespec cnvrtDosUnixTm(__u16 dat >+ ts.tv_nsec = 0; >+ return ts; >+ } >++#else >++/* Did not merge changeset 268f3be177ce93791da38facc34126b5038cd851 >++ * and related time fixes into this function for 2.4 case >++ */ >++time_t >++cifs_NTtimeToUnix(__u64 ntutc) >++{ >++ /* BB what about the timezone? BB */ >++ >++ /* Subtract the NTFS time offset, then convert to 1s intervals. */ >++ u64 t; >++ >++ t = ntutc - NTFS_TIME_OFFSET; >++ do_div(t, 10000000); >++ return (time_t)t; >++} >++ >++/* Convert the Unix UTC into NT UTC. */ >++__u64 >++cifs_UnixTimeToNT(time_t t) >++{ >++ __u64 dce_time; >++ /* Convert to 100ns intervals and then add the NTFS time offset. */ >++ dce_time = (__u64) t * 10000000; >++ dce_time += NTFS_TIME_OFFSET; >++ return dce_time; >++} >++time_t cnvrtDosUnixTm(__u16 date, __u16 time) >++{ >++ __u8 dt[2]; >++ __u8 tm[2]; >++ time_t ts; >++ int sec,min, days, month, year; >++/* SMB_TIME * st = (SMB_TIME *)&time;*/ >++ >++ cFYI(1,("date %d time %d",date, time)); >++ >++ dt[0] = date & 0xFF; >++ dt[1] = (date & 0xFF00) >> 8; >++ tm[0] = time & 0xFF; >++ tm[1] = (time & 0xFF00) >> 8; >++ >++ sec = tm[0] & 0x1F; >++ sec = 2 * sec; >++ min = ((tm[0] >>5)&0xFF) + ((tm[1] & 0x7)<<3); >++ >++ sec += (min * 60); >++ sec += 60 * 60 * ((tm[1] >> 3) &0xFF) /* hours */; >++ days = (dt[0] & 0x1F) - 1; >++ month = ((dt[0] >> 5) & 0xFF) + ((dt[1] & 0x1) <<3); >++ if(month > 12) >++ cERROR(1,("illegal month %d in date", month)); >++ month -= 1; >++ days += total_days_of_prev_months[month]; >++ days += 3653; /* account for difference in days between 1980 and 1970 */ >++ year = (dt[1]>>1) & 0xFF; >++ days += year * 365; >++ days += (year/4); /* leap year */ >++ /* generalized leap year calculation is more complex, ie no leap year >++ for years/100 except for years/400, but since the maximum number for DOS >++ year is 2**7, the last year is 1980+127, which means we need only >++ consider 2 special case years, ie the years 2000 and 2100, and only >++ adjust for the lack of leap year for the year 2100, as 2000 was a >++ leap year (divisable by 400) */ >++ if(year >= 120) /* the year 2100 */ >++ days = days - 1; /* do not count leap year for the year 2100 */ >++ >++ /* adjust for leap year where we are still before leap day */ >++ days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0); >++ sec += 24 * 60 * 60 * days; >++ >++ ts = (time_t)sec; >++ >++ return ts; >++} >++#endif >++ >+diff -up linux-2.6.23.i386/fs/cifs/connect.c.pre150c linux-2.6.23.i386/fs/cifs/connect.c >+--- linux-2.6.23.i386/fs/cifs/connect.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/connect.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -27,12 +27,17 @@ >+ #include <linux/pagemap.h> >+ #include <linux/ctype.h> >+ #include <linux/utsname.h> >+-#include <linux/mempool.h> >+ #include <linux/delay.h> >+ #include <linux/completion.h> >+-#include <linux/kthread.h> >++#include <linux/version.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >++#include <linux/mempool.h> >+ #include <linux/pagevec.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19) >+ #include <linux/freezer.h> >++#endif /* 2.6.19 */ >++#endif >++#include <linux/kthread.h> >+ #include <asm/uaccess.h> >+ #include <asm/processor.h> >+ #include "cifspdu.h" >+@@ -49,12 +54,22 @@ >+ #define CIFS_PORT 445 >+ #define RFC1001_PORT 139 >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 7) >++#define sock_create_kern sock_create >++#endif >++ >+ static DECLARE_COMPLETION(cifsd_complete); >+ >+ extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, >+ unsigned char *p24); >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ extern mempool_t *cifs_req_poolp; >++#else /* old 2.4 kernel */ >++#ifndef PAGEVEC_SIZE >++#define PAGEVEC_SIZE 14 >++#endif >++#endif >+ >+ struct smb_vol { >+ char *username; >+@@ -151,10 +166,9 @@ cifs_reconnect(struct TCP_Server_Info *s >+ } >+ list_for_each(tmp, &GlobalTreeConnectionList) { >+ tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); >+- if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) { >++ if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) >+ tcon->tidStatus = CifsNeedReconnect; >+ } >+- } >+ read_unlock(&GlobalSMBSeslock); >+ /* do not want to be sending data on a socket we are freeing */ >+ down(&server->tcpSem); >+@@ -188,7 +202,9 @@ cifs_reconnect(struct TCP_Server_Info *s >+ up(&server->tcpSem); >+ >+ while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12) >+ try_to_freeze(); >++#endif >+ if (server->protocolType == IPV6) { >+ rc = ipv6_connect(&server->addr.sockAddr6, >+ &server->ssocket); >+@@ -349,6 +365,14 @@ cifs_demultiplex_thread(struct TCP_Serve >+ int isLargeBuf = FALSE; >+ int isMultiRsp; >+ int reconnect; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ mm_segment_t temp_fs; >++#endif >++ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) >++ daemonize(); >++ sprintf(current->comm,"cifsd"); >++#endif >+ >+ current->flags |= PF_MEMALLOC; >+ server->tsk = current; /* save process info to wake at shutdown */ >+@@ -358,16 +382,24 @@ cifs_demultiplex_thread(struct TCP_Serve >+ length = tcpSesAllocCount.counter; >+ write_unlock(&GlobalSMBSeslock); >+ complete(&cifsd_complete); >+- if (length > 1) { >+- mempool_resize(cifs_req_poolp, >+- length + cifs_min_rcv, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10) >++ if (length > 1) >++ mempool_resize(cifs_req_poolp, length + cifs_min_rcv, >+ GFP_KERNEL); >+- } >++#endif >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ temp_fs = get_fs(); /* we must turn off socket api parm checking */ >++ set_fs(get_ds()); >++#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >+ set_freezable(); >++#endif >++ >+ while (!kthread_should_stop()) { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12) >+ if (try_to_freeze()) >+ continue; >++#endif >+ if (bigbuf == NULL) { >+ bigbuf = cifs_buf_get(); >+ if (!bigbuf) { >+@@ -400,11 +432,18 @@ cifs_demultiplex_thread(struct TCP_Serve >+ iov.iov_len = 4; >+ smb_msg.msg_control = NULL; >+ smb_msg.msg_controllen = 0; >+- pdu_length = 4; /* enough to get RFC1001 header */ >++ pdu_length = 4; /* enought to get RFC1001 header */ >+ incomplete_rcv: >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ smb_msg.msg_iov = &iov; >++ smb_msg.msg_iovlen = 1; >++ length = >++ sock_recvmsg(csocket, &smb_msg, pdu_length, 0); >++#else >+ length = >+ kernel_recvmsg(csocket, &smb_msg, >+ &iov, 1, pdu_length, 0 /* BB other flags? */); >++#endif >+ >+ if ( kthread_should_stop() ) { >+ break; >+@@ -418,9 +457,6 @@ incomplete_rcv: >+ msleep(1); /* minimum sleep to prevent looping >+ allowing socket to clear and app threads to set >+ tcpStatus CifsNeedReconnect if server hung */ >+- if (pdu_length < 4) >+- goto incomplete_rcv; >+- else >+ continue; >+ } else if (length <= 0) { >+ if (server->tcpStatus == CifsNew) { >+@@ -431,7 +467,11 @@ incomplete_rcv: >+ and so simply return error to mount */ >+ break; >+ } >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 12) >+ if (!try_to_freeze() && (length == -EINTR)) { >++#else >++ if (length == -EINTR) { >++#endif >+ cFYI(1, ("cifsd thread killed")); >+ break; >+ } >+@@ -529,8 +569,13 @@ incomplete_rcv: >+ iov.iov_len = pdu_length; >+ for (total_read = 0; total_read < pdu_length; >+ total_read += length) { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ length = sock_recvmsg(csocket, &smb_msg, >++ pdu_length - total_read, 0); >++#else >+ length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, >+ pdu_length - total_read, 0); >++#endif >+ if ( kthread_should_stop() || >+ (length == -EINTR)) { >+ /* then will exit */ >+@@ -549,7 +594,6 @@ incomplete_rcv: >+ allowing socket to clear and app >+ threads to set tcpStatus >+ CifsNeedReconnect if server hung*/ >+- length = 0; >+ continue; >+ } else if (length <= 0) { >+ cERROR(1, ("Received no data, expecting %d", >+@@ -635,9 +679,9 @@ multi_t2_fnd: >+ /* Was previous buf put in mpx struct for multi-rsp? */ >+ if (!isMultiRsp) { >+ /* smb buffer will be freed by user thread */ >+- if (isLargeBuf) { >++ if (isLargeBuf) >+ bigbuf = NULL; >+- } else >++ else >+ smallbuf = NULL; >+ } >+ wake_up_process(task_to_wake); >+@@ -679,6 +723,9 @@ multi_t2_fnd: >+ sock_release(csocket); >+ server->ssocket = NULL; >+ } >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8) >++ set_fs(temp_fs); >++#endif >+ /* buffer usuallly freed in free_mid - need to free it here on exit */ >+ if (bigbuf != NULL) >+ cifs_buf_release(bigbuf); >+@@ -706,10 +753,9 @@ multi_t2_fnd: >+ list_for_each(tmp, &GlobalSMBSessionList) { >+ ses = list_entry(tmp, struct cifsSesInfo, >+ cifsSessionList); >+- if (ses->server == server) { >++ if (ses->server == server) >+ ses->status = CifsExiting; >+ } >+- } >+ >+ spin_lock(&GlobalMid_Lock); >+ list_for_each(tmp, &server->pending_mid_q) { >+@@ -718,11 +764,10 @@ multi_t2_fnd: >+ cFYI(1, ("Clearing Mid 0x%x - waking up ", >+ mid_entry->mid)); >+ task_to_wake = mid_entry->tsk; >+- if (task_to_wake) { >++ if (task_to_wake) >+ wake_up_process(task_to_wake); >+ } >+ } >+- } >+ spin_unlock(&GlobalMid_Lock); >+ read_unlock(&GlobalSMBSeslock); >+ /* 1/8th of sec is more than enough time for them to exit */ >+@@ -753,19 +798,19 @@ multi_t2_fnd: >+ list_for_each(tmp, &GlobalSMBSessionList) { >+ ses = list_entry(tmp, struct cifsSesInfo, >+ cifsSessionList); >+- if (ses->server == server) { >++ if (ses->server == server) >+ ses->server = NULL; >+ } >+- } >+ write_unlock(&GlobalSMBSeslock); >+ >+ kfree(server); >+- if (length > 0) { >+- mempool_resize(cifs_req_poolp, >+- length + cifs_min_rcv, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >++ if (length > 0) >++ mempool_resize(cifs_req_poolp, length + cifs_min_rcv, >+ GFP_KERNEL); >+- } >++#endif >+ >++ /* BB PORT - do we need complete_and_exit here? BB */ >+ return 0; >+ } >+ >+@@ -784,7 +829,11 @@ cifs_parse_mount_options(char *options, >+ if (Local_System_Name[0] != 0) >+ memcpy(vol->source_rfc1001_name, Local_System_Name, 15); >+ else { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ char *nodename = utsname()->nodename; >++#else >++ char *nodename = system_utsname.nodename; >++#endif >+ int n = strnlen(nodename, 15); >+ memset(vol->source_rfc1001_name, 0x20, 15); >+ for (i = 0; i < n; i++) { >+@@ -1473,7 +1522,11 @@ ipv4_connect(struct sockaddr_in *psin_se >+ } else { >+ /* BB other socket options to set KEEPALIVE, NODELAY? */ >+ cFYI(1, ("Socket created")); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ (*csocket)->sk->sk_allocation = GFP_NOFS; >++#else >++ (*csocket)->sk->allocation = GFP_NOFS; >++#endif >+ } >+ } >+ >+@@ -1524,6 +1577,7 @@ ipv4_connect(struct sockaddr_in *psin_se >+ /* Eventually check for other socket options to change from >+ the default. sock_setsockopt not used because it expects >+ user space buffer */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ cFYI(1, ("sndbuf %d rcvbuf %d rcvtimeo 0x%lx", >+ (*csocket)->sk->sk_sndbuf, >+ (*csocket)->sk->sk_rcvbuf, (*csocket)->sk->sk_rcvtimeo)); >+@@ -1533,6 +1587,16 @@ ipv4_connect(struct sockaddr_in *psin_se >+ (*csocket)->sk->sk_sndbuf = 200 * 1024; >+ if ((*csocket)->sk->sk_rcvbuf < (140 * 1024)) >+ (*csocket)->sk->sk_rcvbuf = 140 * 1024; >++#else >++ cFYI(1,("sndbuf %d rcvbuf %d rcvtimeo 0x%lx",(*csocket)->sk->sndbuf, >++ (*csocket)->sk->rcvbuf, (*csocket)->sk->rcvtimeo)); >++ (*csocket)->sk->rcvtimeo = 7 * HZ; >++ /* make the bufsizes depend on wsize/rsize and max requests */ >++ if((*csocket)->sk->sndbuf < (200 * 1024)) >++ (*csocket)->sk->sndbuf = 200 * 1024; >++ if((*csocket)->sk->rcvbuf < (140 * 1024)) >++ (*csocket)->sk->rcvbuf = 140 * 1024; >++#endif >+ >+ /* send RFC1001 sessinit */ >+ if (psin_server->sin_port == htons(RFC1001_PORT)) { >+@@ -1605,7 +1669,11 @@ ipv6_connect(struct sockaddr_in6 *psin_s >+ } else { >+ /* BB other socket options to set KEEPALIVE, NODELAY? */ >+ cFYI(1, ("ipv6 Socket created")); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ (*csocket)->sk->sk_allocation = GFP_NOFS; >++#else >++ (*csocket)->sk->allocation = GFP_NOFS; >++#endif >+ } >+ } >+ >+@@ -1656,7 +1724,11 @@ ipv6_connect(struct sockaddr_in6 *psin_s >+ /* Eventually check for other socket options to change from >+ the default. sock_setsockopt not used because it expects >+ user space buffer */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ (*csocket)->sk->sk_rcvtimeo = 7 * HZ; >++#else >++ (*csocket)->sk->rcvtimeo = 7 * HZ; >++#endif >+ >+ return rc; >+ } >+@@ -1706,9 +1778,13 @@ void reset_cifs_unix_caps(int xid, struc >+ if (vol_info && vol_info->no_psx_acl) >+ cap &= ~CIFS_UNIX_POSIX_ACL_CAP; >+ else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ cFYI(1, ("negotiated posix acl support")); >+ if (sb) >+ sb->s_flags |= MS_POSIXACL; >++#else >++ cFYI(1,("ACLs not supported")); >++#endif >+ } >+ >+ if (vol_info && vol_info->posix_paths == 0) >+@@ -1754,7 +1830,16 @@ void reset_cifs_unix_caps(int xid, struc >+ cFYI(1, ("very large write cap")); >+ #endif /* CIFS_DEBUG2 */ >+ if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) { >+- cFYI(1, ("setting capabilities failed")); >++ if (vol_info == NULL) >++ cFYI(1, ("resetting capabilities failed")); >++ else >++ cERROR(1, ("Negotiating Unix capabilities " >++ "with the server failed. Consider " >++ "mounting with the Unix Extensions\n" >++ "disabled, if problems are found, " >++ "by specifying the nounix mount " >++ "option.")); >++ >+ } >+ } >+ } >+@@ -1790,7 +1875,7 @@ cifs_mount(struct super_block *sb, struc >+ >+ if (volume_info.nullauth) { >+ cFYI(1, ("null user")); >+- volume_info.username = ""; >++ volume_info.username = NULL; >+ } else if (volume_info.username) { >+ /* BB fixme parse for domain name here */ >+ cFYI(1, ("Username: %s", volume_info.username)); >+@@ -2134,8 +2219,10 @@ cifs_mount(struct super_block *sb, struc >+ sb->s_maxbytes = (u64) 1 << 31; /* 2 GB */ >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10) >+ /* BB FIXME fix time_gran to be larger for LANMAN sessions */ >+ sb->s_time_gran = 100; >++#endif >+ >+ /* on error free sesinfo and tcon struct if needed */ >+ if (rc) { >+@@ -2326,8 +2413,13 @@ CIFSSessSetup(unsigned int xid, struct c >+ 32, nls_codepage); >+ bcc_ptr += 2 * bytes_returned; >+ bytes_returned = >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ cifs_strtoUCS((__le16 *) bcc_ptr, utsname()->release, >+ 32, nls_codepage); >++#else >++ cifs_strtoUCS((__le16 *)bcc_ptr, system_utsname.release, >++ 32, nls_codepage); >++#endif >+ bcc_ptr += 2 * bytes_returned; >+ bcc_ptr += 2; >+ bytes_returned = >+@@ -2353,8 +2445,13 @@ CIFSSessSetup(unsigned int xid, struct c >+ } >+ strcpy(bcc_ptr, "Linux version "); >+ bcc_ptr += strlen("Linux version "); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ strcpy(bcc_ptr, utsname()->release); >+ bcc_ptr += strlen(utsname()->release) + 1; >++#else >++ strcpy(bcc_ptr, system_utsname.release); >++ bcc_ptr += strlen(system_utsname.release) + 1; >++#endif >+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); >+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; >+ } >+@@ -2637,8 +2734,13 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned i >+ 32, nls_codepage); >+ bcc_ptr += 2 * bytes_returned; >+ bytes_returned = >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ cifs_strtoUCS((__le16 *) bcc_ptr, utsname()->release, 32, >+ nls_codepage); >++#else >++ cifs_strtoUCS((__le16 *)bcc_ptr, system_utsname.release, 32, >++ nls_codepage); >++#endif >+ bcc_ptr += 2 * bytes_returned; >+ bcc_ptr += 2; /* null terminate Linux version */ >+ bytes_returned = >+@@ -2654,8 +2756,13 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned i >+ } else { /* ASCII */ >+ strcpy(bcc_ptr, "Linux version "); >+ bcc_ptr += strlen("Linux version "); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ strcpy(bcc_ptr, utsname()->release); >+ bcc_ptr += strlen(utsname()->release) + 1; >++#else >++ strcpy(bcc_ptr, system_utsname.release); >++ bcc_ptr += strlen(system_utsname.release) + 1; >++#endif >+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); >+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; >+ bcc_ptr++; /* empty domain field */ >+@@ -2983,36 +3090,32 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xi >+ SecurityBlob->DomainName.Length = 0; >+ SecurityBlob->DomainName.MaximumLength = 0; >+ } else { >+- __u16 len = >+- cifs_strtoUCS((__le16 *) bcc_ptr, domain, 64, >++ __u16 ln = cifs_strtoUCS((__le16 *) bcc_ptr, domain, 64, >+ nls_codepage); >+- len *= 2; >++ ln *= 2; >+ SecurityBlob->DomainName.MaximumLength = >+- cpu_to_le16(len); >++ cpu_to_le16(ln); >+ SecurityBlob->DomainName.Buffer = >+ cpu_to_le32(SecurityBlobLength); >+- bcc_ptr += len; >+- SecurityBlobLength += len; >+- SecurityBlob->DomainName.Length = >+- cpu_to_le16(len); >++ bcc_ptr += ln; >++ SecurityBlobLength += ln; >++ SecurityBlob->DomainName.Length = cpu_to_le16(ln); >+ } >+ if (user == NULL) { >+ SecurityBlob->UserName.Buffer = 0; >+ SecurityBlob->UserName.Length = 0; >+ SecurityBlob->UserName.MaximumLength = 0; >+ } else { >+- __u16 len = >+- cifs_strtoUCS((__le16 *) bcc_ptr, user, 64, >++ __u16 ln = cifs_strtoUCS((__le16 *) bcc_ptr, user, 64, >+ nls_codepage); >+- len *= 2; >++ ln *= 2; >+ SecurityBlob->UserName.MaximumLength = >+- cpu_to_le16(len); >++ cpu_to_le16(ln); >+ SecurityBlob->UserName.Buffer = >+ cpu_to_le32(SecurityBlobLength); >+- bcc_ptr += len; >+- SecurityBlobLength += len; >+- SecurityBlob->UserName.Length = >+- cpu_to_le16(len); >++ bcc_ptr += ln; >++ SecurityBlobLength += ln; >++ SecurityBlob->UserName.Length = cpu_to_le16(ln); >+ } >+ >+ /* SecurityBlob->WorkstationName.Length = >+@@ -3036,8 +3139,13 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xi >+ 32, nls_codepage); >+ bcc_ptr += 2 * bytes_returned; >+ bytes_returned = >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ cifs_strtoUCS((__le16 *) bcc_ptr, utsname()->release, 32, >+ nls_codepage); >++#else >++ cifs_strtoUCS((__le16 *) bcc_ptr, system_utsname.release, 32, >++ nls_codepage); >++#endif >+ bcc_ptr += 2 * bytes_returned; >+ bcc_ptr += 2; /* null term version string */ >+ bytes_returned = >+@@ -3056,40 +3164,44 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xi >+ SecurityBlob->DomainName.Length = 0; >+ SecurityBlob->DomainName.MaximumLength = 0; >+ } else { >+- __u16 len; >++ __u16 ln; >+ negotiate_flags |= NTLMSSP_NEGOTIATE_DOMAIN_SUPPLIED; >+ strncpy(bcc_ptr, domain, 63); >+- len = strnlen(domain, 64); >++ ln = strnlen(domain, 64); >+ SecurityBlob->DomainName.MaximumLength = >+- cpu_to_le16(len); >++ cpu_to_le16(ln); >+ SecurityBlob->DomainName.Buffer = >+ cpu_to_le32(SecurityBlobLength); >+- bcc_ptr += len; >+- SecurityBlobLength += len; >+- SecurityBlob->DomainName.Length = cpu_to_le16(len); >++ bcc_ptr += ln; >++ SecurityBlobLength += ln; >++ SecurityBlob->DomainName.Length = cpu_to_le16(ln); >+ } >+ if (user == NULL) { >+ SecurityBlob->UserName.Buffer = 0; >+ SecurityBlob->UserName.Length = 0; >+ SecurityBlob->UserName.MaximumLength = 0; >+ } else { >+- __u16 len; >++ __u16 ln; >+ strncpy(bcc_ptr, user, 63); >+- len = strnlen(user, 64); >+- SecurityBlob->UserName.MaximumLength = >+- cpu_to_le16(len); >++ ln = strnlen(user, 64); >++ SecurityBlob->UserName.MaximumLength = cpu_to_le16(ln); >+ SecurityBlob->UserName.Buffer = >+ cpu_to_le32(SecurityBlobLength); >+- bcc_ptr += len; >+- SecurityBlobLength += len; >+- SecurityBlob->UserName.Length = cpu_to_le16(len); >++ bcc_ptr += ln; >++ SecurityBlobLength += ln; >++ SecurityBlob->UserName.Length = cpu_to_le16(ln); >+ } >+ /* BB fill in our workstation name if known BB */ >+ >+ strcpy(bcc_ptr, "Linux version "); >+ bcc_ptr += strlen("Linux version "); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18) >+ strcpy(bcc_ptr, utsname()->release); >+ bcc_ptr += strlen(utsname()->release) + 1; >++#else >++ strcpy(bcc_ptr, system_utsname.release); >++ bcc_ptr += strlen(system_utsname.release) + 1; >++#endif >+ strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); >+ bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; >+ bcc_ptr++; /* null domain */ >+@@ -3149,8 +3261,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xi >+ } else { >+ remaining_words = BCC(smb_buffer_response) / 2; >+ } >+- len = >+- UniStrnlen((wchar_t *) bcc_ptr,remaining_words - 1); >++ len = UniStrnlen((wchar_t *) bcc_ptr, >++ remaining_words - 1); >+ /* We look for obvious messed up bcc or strings in response so we do not go off >+ the end since (at least) WIN2K and Windows XP have a major bug in not null >+ terminating last Unicode string in response */ >+@@ -3403,7 +3515,9 @@ CIFSTCon(unsigned int xid, struct cifsSe >+ kfree(tcon->nativeFileSystem); >+ tcon->nativeFileSystem = >+ kzalloc(length + 2, GFP_KERNEL); >+- cifs_strfromUCS_le(tcon->nativeFileSystem, >++ if (tcon->nativeFileSystem) >++ cifs_strfromUCS_le( >++ tcon->nativeFileSystem, >+ (__le16 *) bcc_ptr, >+ length, nls_codepage); >+ bcc_ptr += 2 * length; >+@@ -3420,6 +3534,7 @@ CIFSTCon(unsigned int xid, struct cifsSe >+ kfree(tcon->nativeFileSystem); >+ tcon->nativeFileSystem = >+ kzalloc(length + 1, GFP_KERNEL); >++ if (tcon->nativeFileSystem) >+ strncpy(tcon->nativeFileSystem, bcc_ptr, >+ length); >+ } >+@@ -3488,7 +3603,12 @@ cifs_umount(struct super_block *sb, stru >+ cifs_sb->prepath = NULL; >+ kfree(tmp); >+ if (ses) >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14) >++ set_current_state(TASK_INTERRUPTIBLE); >++ schedule_timeout(HZ / 2); >++#else >+ schedule_timeout_interruptible(msecs_to_jiffies(500)); >++#endif >+ if (ses) >+ sesInfoFree(ses); >+ >+diff -up linux-2.6.23.i386/fs/cifs/inode.c.pre150c linux-2.6.23.i386/fs/cifs/inode.c >+--- linux-2.6.23.i386/fs/cifs/inode.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/inode.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -28,6 +28,26 @@ >+ #include "cifsproto.h" >+ #include "cifs_debug.h" >+ #include "cifs_fs_sb.h" >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >++#include <linux/buffer_head.h> >++#endif >++ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) >++static inline void clear_nlink(struct inode *inode) >++{ >++ inode->i_nlink = 0; >++} >++static inline void drop_nlink(struct inode *inode) >++{ >++ inode->i_nlink--; >++} >++ >++static inline void inc_nlink(struct inode *inode) >++{ >++ inode->i_nlink++; >++} >++#endif >++ >+ >+ int cifs_get_inode_info_unix(struct inode **pinode, >+ const unsigned char *search_path, struct super_block *sb, int xid) >+@@ -69,6 +89,8 @@ int cifs_get_inode_info_unix(struct inod >+ kfree(tmp_path); >+ >+ /* BB fix up inode etc. */ >++ } else if (rc == -EOPNOTSUPP) { >++ cifs_get_inode_info(pinode, search_path, NULL, sb, xid); >+ } else if (rc) { >+ return rc; >+ } >+@@ -919,18 +941,24 @@ int cifs_mkdir(struct inode *inode, stru >+ goto mkdir_out; >+ } >+ >++ mode &= ~current->fs->umask; >+ rc = CIFSPOSIXCreate(xid, pTcon, SMB_O_DIRECTORY | SMB_O_CREAT, >+ mode, NULL /* netfid */, pInfo, &oplock, >+ full_path, cifs_sb->local_nls, >+ cifs_sb->mnt_cifs_flags & >+ CIFS_MOUNT_MAP_SPECIAL_CHR); >+- if (rc) { >++ if (rc == -EOPNOTSUPP) { >++ kfree(pInfo); >++ goto mkdir_retry_old; >++ } else if (rc) { >+ cFYI(1, ("posix mkdir returned 0x%x", rc)); >+ d_drop(direntry); >+ } else { >+ int obj_type; >+- if (pInfo->Type == -1) /* no return info - go query */ >++ if (pInfo->Type == -1) /* no return info - go query */ { >++ kfree(pInfo); >+ goto mkdir_get_info; >++ } >+ /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need >+ to set uid/gid */ >+ inc_nlink(inode); >+@@ -940,8 +968,10 @@ int cifs_mkdir(struct inode *inode, stru >+ direntry->d_op = &cifs_dentry_ops; >+ >+ newinode = new_inode(inode->i_sb); >+- if (newinode == NULL) >++ if (newinode == NULL) { >++ kfree(pInfo); >+ goto mkdir_get_info; >++ } >+ /* Is an i_ino of zero legal? */ >+ /* Are there sanity checks we can use to ensure that >+ the server is really filling in that field? */ >+@@ -972,7 +1002,7 @@ int cifs_mkdir(struct inode *inode, stru >+ kfree(pInfo); >+ goto mkdir_out; >+ } >+- >++mkdir_retry_old: >+ /* BB add setting the equivalent of mode via CreateX w/ACLs */ >+ rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls, >+ cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); >+@@ -1210,7 +1240,11 @@ int cifs_revalidate(struct dentry *diren >+ struct cifs_sb_info *cifs_sb; >+ struct cifsInodeInfo *cifsInode; >+ loff_t local_size; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct timespec local_mtime; >++#else >++ time_t local_mtime; >++#endif >+ int invalidate_inode = FALSE; >+ >+ if (direntry->d_inode == NULL) >+@@ -1331,6 +1365,7 @@ int cifs_revalidate(struct dentry *diren >+ return rc; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry, >+ struct kstat *stat) >+ { >+@@ -1341,19 +1376,28 @@ int cifs_getattr(struct vfsmount *mnt, s >+ } >+ return err; >+ } >++#endif >+ >+ static int cifs_truncate_page(struct address_space *mapping, loff_t from) >+ { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ pgoff_t index = from >> PAGE_CACHE_SHIFT; >++#else >++ unsigned long index = from >> PAGE_CACHE_SHIFT; >++#endif >+ unsigned offset = from & (PAGE_CACHE_SIZE - 1); >+ struct page *page; >++ char *kaddr; >+ int rc = 0; >+ >+ page = grab_cache_page(mapping, index); >+ if (!page) >+ return -ENOMEM; >+ >+- zero_user_page(page, offset, PAGE_CACHE_SIZE - offset, KM_USER0); >++ kaddr = kmap_atomic(page, KM_USER0); >++ memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset); >++ flush_dcache_page(page); >++ kunmap_atomic(kaddr, KM_USER0); >+ unlock_page(page); >+ page_cache_release(page); >+ return rc; >+@@ -1377,12 +1421,25 @@ static int cifs_vmtruncate(struct inode >+ } >+ i_size_write(inode, offset); >+ spin_unlock(&inode->i_lock); >++ /* >++ * unmap_mapping_range is called twice, first simply for efficiency >++ * so that truncate_inode_pages does fewer single-page unmaps. However >++ * after this first call, and before truncate_inode_pages finishes, >++ * it is possible for private pages to be COWed, which remain after >++ * truncate_inode_pages finishes, hence the second unmap_mapping_range >++ * call must be made for correctness. >++ */ >+ unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); >+ truncate_inode_pages(mapping, offset); >++ unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); >+ goto out_truncate; >+ >+ do_expand: >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 10) >++ limit = current->rlim[RLIMIT_FSIZE].rlim_cur; >++#else >+ limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; >++#endif >+ if (limit != RLIM_INFINITY && offset > limit) { >+ spin_unlock(&inode->i_lock); >+ goto out_sig; >+@@ -1449,7 +1506,12 @@ int cifs_setattr(struct dentry *direntry >+ /* BB check if we need to refresh inode from server now ? BB */ >+ >+ /* need to flush data before changing file size on server */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 15) >+ filemap_write_and_wait(direntry->d_inode->i_mapping); >++#else >++ filemap_fdatawrite(direntry->d_inode->i_mapping); >++ filemap_fdatawait(direntry->d_inode->i_mapping); >++#endif >+ >+ if (attrs->ia_valid & ATTR_SIZE) { >+ /* To avoid spurious oplock breaks from server, in the case of >+@@ -1469,7 +1531,7 @@ int cifs_setattr(struct dentry *direntry >+ atomic_dec(&open_file->wrtPending); >+ cFYI(1, ("SetFSize for attrs rc = %d", rc)); >+ if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { >+- int bytes_written; >++ unsigned int bytes_written; >+ rc = CIFSSMBWrite(xid, pTcon, >+ nfid, 0, attrs->ia_size, >+ &bytes_written, NULL, NULL, >+@@ -1502,7 +1564,7 @@ int cifs_setattr(struct dentry *direntry >+ cifs_sb->mnt_cifs_flags & >+ CIFS_MOUNT_MAP_SPECIAL_CHR); >+ if (rc == 0) { >+- int bytes_written; >++ unsigned int bytes_written; >+ rc = CIFSSMBWrite(xid, pTcon, >+ netfid, 0, >+ attrs->ia_size, >+diff -up linux-2.6.23.i386/fs/cifs/fcntl.c.pre150c linux-2.6.23.i386/fs/cifs/fcntl.c >+--- linux-2.6.23.i386/fs/cifs/fcntl.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/fcntl.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -81,10 +81,17 @@ int cifs_dir_notify(struct file *file, u >+ return 0; >+ >+ xid = GetXid(); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++ pTcon = cifs_sb->tcon; >++ >++ full_path = build_path_from_dentry(file->f_dentry); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >+ pTcon = cifs_sb->tcon; >+ >+ full_path = build_path_from_dentry(file->f_path.dentry); >++#endif >+ >+ if (full_path == NULL) { >+ rc = -ENOMEM; >+diff -up linux-2.6.23.i386/fs/cifs/readdir.c.pre150c linux-2.6.23.i386/fs/cifs/readdir.c >+--- linux-2.6.23.i386/fs/cifs/readdir.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/readdir.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -23,6 +23,7 @@ >+ #include <linux/fs.h> >+ #include <linux/pagemap.h> >+ #include <linux/stat.h> >++#include <linux/smp_lock.h> >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+ #include "cifsproto.h" >+@@ -66,6 +67,20 @@ static int construct_dentry(struct qstr >+ int rc = 0; >+ >+ cFYI(1, ("For %s", qstring->name)); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++ pTcon = cifs_sb->tcon; >++ >++ qstring->hash = full_name_hash(qstring->name, qstring->len); >++ tmp_dentry = d_lookup(file->f_dentry, qstring); >++ if (tmp_dentry) { >++ 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_dentry->d_sb); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >+ pTcon = cifs_sb->tcon; >+ >+@@ -78,28 +93,44 @@ static int construct_dentry(struct qstr >+ /* 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); >++#endif >+ if (*ptmp_inode == NULL) >+ return rc; >+ rc = 1; >+ } >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19) >+ if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME) >++#else >++ if (file->f_dentry->d_sb->s_flags & MS_NOATIME) >++#endif >+ (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; >+ } else { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ tmp_dentry = d_alloc(file->f_dentry, qstring); >++#else >+ tmp_dentry = d_alloc(file->f_path.dentry, qstring); >++#endif >+ if (tmp_dentry == NULL) { >+ cERROR(1, ("Failed allocating dentry")); >+ *ptmp_inode = NULL; >+ return rc; >+ } >+- >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ *ptmp_inode = new_inode(file->f_dentry->d_sb); >++#else >+ *ptmp_inode = new_inode(file->f_path.dentry->d_sb); >++#endif >+ if (pTcon->nocase) >+ tmp_dentry->d_op = &cifs_ci_dentry_ops; >+ else >+ tmp_dentry->d_op = &cifs_dentry_ops; >+ if (*ptmp_inode == NULL) >+ return rc; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19) >+ if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME) >++#else >++ if (file->f_dentry->d_sb->s_flags & MS_NOATIME) >++#endif >+ (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; >+ rc = 2; >+ } >+@@ -112,9 +143,15 @@ static int construct_dentry(struct qstr >+ static void AdjustForTZ(struct cifsTconInfo *tcon, struct inode *inode) >+ { >+ if ((tcon) && (tcon->ses) && (tcon->ses->server)) { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ inode->i_ctime.tv_sec += tcon->ses->server->timeAdj; >+ inode->i_mtime.tv_sec += tcon->ses->server->timeAdj; >+ inode->i_atime.tv_sec += tcon->ses->server->timeAdj; >++#else >++ inode->i_ctime += tcon->ses->server->timeAdj; >++ inode->i_mtime += tcon->ses->server->timeAdj; >++ inode->i_atime += tcon->ses->server->timeAdj; >++#endif >+ } >+ return; >+ } >+@@ -124,7 +161,12 @@ static void fill_in_inode(struct inode * >+ char *buf, int *pobject_type, int isNewInode) >+ { >+ loff_t local_size; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct timespec local_mtime; >++#else >++ time_t local_mtime; >++#endif >++ >+ >+ struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); >+ struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); >+@@ -297,7 +339,11 @@ static void unix_fill_in_inode(struct in >+ FILE_UNIX_INFO *pfindData, int *pobject_type, int isNewInode) >+ { >+ loff_t local_size; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct timespec local_mtime; >++#else >++ time_t local_mtime; >++#endif >+ >+ struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); >+ struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); >+@@ -445,6 +491,17 @@ static int initiate_cifs_search(const in >+ cifsFile->invalidHandle = TRUE; >+ cifsFile->srch_inf.endOfSearch = FALSE; >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++ if (cifs_sb == NULL) >++ return -EINVAL; >++ >++ pTcon = cifs_sb->tcon; >++ if (pTcon == NULL) >++ return -EINVAL; >++ >++ full_path = build_path_from_dentry(file->f_dentry); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >+ if (cifs_sb == NULL) >+ return -EINVAL; >+@@ -454,6 +511,7 @@ static int initiate_cifs_search(const in >+ return -EINVAL; >+ >+ full_path = build_path_from_dentry(file->f_path.dentry); >++#endif >+ >+ if (full_path == NULL) { >+ return -ENOMEM; >+@@ -619,7 +677,11 @@ static int cifs_entry_is_dot(char *curre >+ whether we can use the cached search results from the previous search */ >+ static int is_dir_changed(struct file *file) >+ { >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ struct inode *inode = file->f_dentry->d_inode; >++#else >+ struct inode *inode = file->f_path.dentry->d_inode; >++#endif >+ struct cifsInodeInfo *cifsInfo = CIFS_I(inode); >+ >+ if (cifsInfo->time == 0) >+@@ -848,7 +910,11 @@ static int cifs_filldir(char *pfindEntry >+ if (rc != 0) >+ return 0; >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >++#endif >+ >+ qstring.name = scratch_buf; >+ rc = cifs_get_name_from_search_buf(&qstring, pfindEntry, >+@@ -987,6 +1053,25 @@ int cifs_readdir(struct file *file, void >+ >+ xid = GetXid(); >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) >++ cifs_sb = CIFS_SB(file->f_dentry->d_sb); >++ pTcon = cifs_sb->tcon; >++ if (pTcon == NULL) >++ return -EINVAL; >++ >++ switch ((int) file->f_pos) { >++ case 0: >++ if (filldir(direntry, ".", 1, file->f_pos, >++ file->f_dentry->d_inode->i_ino, DT_DIR) < 0) { >++ cERROR(1, ("Filldir for current dir failed")); >++ rc = -ENOMEM; >++ break; >++ } >++ file->f_pos++; >++ case 1: >++ if (filldir(direntry, "..", 2, file->f_pos, >++ file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { >++#else >+ cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); >+ pTcon = cifs_sb->tcon; >+ if (pTcon == NULL) >+@@ -1004,6 +1089,7 @@ int cifs_readdir(struct file *file, void >+ case 1: >+ if (filldir(direntry, "..", 2, file->f_pos, >+ file->f_path.dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { >++#endif >+ cERROR(1, ("Filldir for parent dir failed")); >+ rc = -ENOMEM; >+ break; >+@@ -1067,7 +1153,7 @@ int cifs_readdir(struct file *file, void >+ for (i = 0; (i < num_to_fill) && (rc == 0); i++) { >+ if (current_entry == NULL) { >+ /* evaluate whether this case is an error */ >+- cERROR(1,("past end of SMB num to fill %d i %d", >++ cERROR(1, ("past SMB end, num to fill %d i %d", >+ num_to_fill, i)); >+ break; >+ } >+diff -up linux-2.6.23.i386/fs/cifs/CHANGES.pre150c linux-2.6.23.i386/fs/cifs/CHANGES >+--- linux-2.6.23.i386/fs/cifs/CHANGES.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/CHANGES 2008-01-09 17:40:28.000000000 +0100 >+@@ -6,7 +6,10 @@ done with "serverino" mount option). Ad >+ Samba supports newer POSIX CIFS Protocol Extensions). Add "nounix" >+ mount option to allow disabling the CIFS Unix Extensions for just >+ that mount. Fix hang on spinlock in find_writable_file (race when >+-reopening file after session crash). >++reopening file after session crash). Byte range unlock request to >++windows server could unlock more bytes (on server copy of file) >++than intended if start of unlock request is well before start of >++a previous byte range lock that we issued. >+ >+ Version 1.49 >+ ------------ >+diff -up linux-2.6.23.i386/fs/cifs/cifsproto.h.pre150c linux-2.6.23.i386/fs/cifs/cifsproto.h >+--- linux-2.6.23.i386/fs/cifs/cifsproto.h.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifsproto.h 2008-01-09 17:40:28.000000000 +0100 >+@@ -21,10 +21,23 @@ >+ #ifndef _CIFSPROTO_H >+ #define _CIFSPROTO_H >+ #include <linux/nls.h> >++#include <linux/version.h> >+ >+ struct statfs; >+ struct smb_vol; >+ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8) >++#define kvec iovec >++#endif >++ >++#ifndef msleep >++#define msleep(x) { set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(x * HZ / 1000); } >++#endif >++ >++#ifndef __user >++#define __user >++#endif >++ >+ /* >+ ***************************************************************** >+ * All Prototypes >+@@ -79,10 +92,16 @@ extern __u16 GetNextMid(struct TCP_Serve >+ extern struct oplock_q_entry *AllocOplockQEntry(struct inode *, u16, >+ struct cifsTconInfo *); >+ extern void DeleteOplockQEntry(struct oplock_q_entry *); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) >+ extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ ); >+ extern u64 cifs_UnixTimeToNT(struct timespec); >+-extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time); >+ extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time); >++#else >++extern u64 cifs_UnixTimeToNT(time_t); >++extern time_t cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ ); >++extern time_t cnvrtDosUnixTm(__u16 date, __u16 time); >++#endif >++extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time); >+ >+ extern int cifs_get_inode_info(struct inode **pinode, >+ const unsigned char *search_path, >+@@ -150,10 +169,17 @@ extern int get_dfs_path(int xid, struct >+ int remap); >+ extern void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon, >+ struct super_block *sb, struct smb_vol *vol); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, >+ struct kstatfs *FSData); >+ extern int SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, >+ struct kstatfs *FSData); >++#else >++extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, >++ struct statfs *FSData); >++extern int SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, >++ struct statfs *FSData); >++#endif >+ extern int CIFSSMBSetFSUnixInfo(const int xid, struct cifsTconInfo *tcon, >+ __u64 cap); >+ >+@@ -162,7 +188,11 @@ extern int CIFSSMBQFSAttributeInfo(const >+ extern int CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon); >+ extern int CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon); >+ extern int CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ struct kstatfs *FSData); >++#else >++ struct statfs *FSData); >++#endif >+ >+ extern int CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, >+ const char *fileName, const FILE_BASIC_INFO * data, >+@@ -346,4 +376,7 @@ extern int CIFSSMBSetPosixACL(const int >+ const struct nls_table *nls_codepage, int remap_special_chars); >+ extern int CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon, >+ const int netfid, __u64 * pExtAttrBits, __u64 *pMask); >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) >++extern void * kzalloc(size_t size, unsigned flgs); >++#endif >+ #endif /* _CIFSPROTO_H */ >+diff -up linux-2.6.23.i386/fs/cifs/cifsfs.h.pre150c linux-2.6.23.i386/fs/cifs/cifsfs.h >+--- linux-2.6.23.i386/fs/cifs/cifsfs.h.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifsfs.h 2008-01-09 17:40:28.000000000 +0100 >+@@ -32,6 +32,35 @@ >+ #define TRUE 1 >+ #endif >+ >++#include <linux/version.h> >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) >++#define current_fs_time(arg) CURRENT_TIME >++#endif >++ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 25) >++#define filemap_fdatawrite filemap_fdatasync >++#endif >++ >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) >++static inline int timespec_equal(time_t *time1, time_t *time2) >++{ >++ return (time1 == time2); >++} >++ >++static inline void invalidate_remote_inode(struct inode * inode) >++{ >++ invalidate_inode_pages(inode); >++} >++ >++static inline void i_size_write(struct inode *inode, loff_t size) >++{ >++ inode->i_size = size; >++} >++#ifndef PageUptodate >++#define PageUptodate(page) Page_Uptodate(page) >++#endif >++#endif >++ >+ extern const struct address_space_operations cifs_addr_ops; >+ extern const struct address_space_operations cifs_addr_ops_smallbuf; >+ >+@@ -43,19 +72,25 @@ extern void cifs_read_inode(struct inode >+ >+ /* Functions related to inodes */ >+ extern const struct inode_operations cifs_dir_inode_ops; >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ extern int cifs_create(struct inode *, struct dentry *, int, >+ struct nameidata *); >+ extern struct dentry *cifs_lookup(struct inode *, struct dentry *, >+ struct nameidata *); >++extern int cifs_mknod(struct inode *, struct dentry *, int, dev_t); >++extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); >++#else >++extern int cifs_create(struct inode *, struct dentry *, int); >++extern struct dentry * cifs_lookup(struct inode *, struct dentry *); >++extern int cifs_mknod(struct inode *, struct dentry *, int, int); >++#endif >+ extern int cifs_unlink(struct inode *, struct dentry *); >+ extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *); >+-extern int cifs_mknod(struct inode *, struct dentry *, int, dev_t); >+ extern int cifs_mkdir(struct inode *, struct dentry *, int); >+ extern int cifs_rmdir(struct inode *, struct dentry *); >+ extern int cifs_rename(struct inode *, struct dentry *, struct inode *, >+ struct dentry *); >+ extern int cifs_revalidate(struct dentry *); >+-extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); >+ extern int cifs_setattr(struct dentry *, struct iattr *); >+ >+ extern const struct inode_operations cifs_file_inode_ops; >+@@ -75,7 +110,11 @@ extern ssize_t cifs_user_write(struct fi >+ size_t write_size, loff_t *poffset); >+ extern int cifs_lock(struct file *, int, struct file_lock *); >+ extern int cifs_fsync(struct file *, struct dentry *, int); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17) >+ extern int cifs_flush(struct file *, fl_owner_t id); >++#else >++extern int cifs_flush(struct file *); >++#endif /* 2.6.17 */ >+ extern int cifs_file_mmap(struct file * , struct vm_area_struct *); >+ extern const struct file_operations cifs_dir_ops; >+ extern int cifs_dir_open(struct inode *inode, struct file *file); >+@@ -87,9 +126,14 @@ extern struct dentry_operations cifs_den >+ extern struct dentry_operations cifs_ci_dentry_ops; >+ >+ /* Functions related to symlinks */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) >+ extern void *cifs_follow_link(struct dentry *direntry, struct nameidata *nd); >+ extern void cifs_put_link(struct dentry *direntry, >+ struct nameidata *nd, void *); >++#else >++extern int cifs_follow_link(struct dentry *direntry, struct nameidata *nd); >++extern void cifs_put_link(struct dentry *direntry, struct nameidata *nd); >++#endif >+ extern int cifs_readlink(struct dentry *direntry, char __user *buffer, >+ int buflen); >+ extern int cifs_symlink(struct inode *inode, struct dentry *direntry, >+@@ -101,5 +145,5 @@ extern ssize_t cifs_getxattr(struct dent >+ extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); >+ extern int cifs_ioctl (struct inode *inode, struct file *filep, >+ unsigned int command, unsigned long arg); >+-#define CIFS_VERSION "1.50" >++#define CIFS_VERSION "1.51" >+ #endif /* _CIFSFS_H */ >+diff -up linux-2.6.23.i386/fs/cifs/misc.c.pre150c linux-2.6.23.i386/fs/cifs/misc.c >+--- linux-2.6.23.i386/fs/cifs/misc.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/misc.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -21,7 +21,10 @@ >+ >+ #include <linux/slab.h> >+ #include <linux/ctype.h> >++#include <linux/version.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ #include <linux/mempool.h> >++#endif >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+ #include "cifsproto.h" >+@@ -30,8 +33,13 @@ >+ #include "nterr.h" >+ #include "cifs_unicode.h" >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ extern mempool_t *cifs_sm_req_poolp; >+ extern mempool_t *cifs_req_poolp; >++#else >++extern kmem_cache_t *cifs_sm_req_cachep; >++extern kmem_cache_t *cifs_req_cachep; >++#endif >+ extern struct task_struct *oplockThread; >+ >+ /* The xid serves as a useful identifier for each incoming vfs request, >+@@ -150,9 +158,13 @@ cifs_buf_get(void) >+ but it may be more efficient to always alloc same size >+ albeit slightly larger than necessary and maxbuffersize >+ defaults to this and can not be bigger */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ ret_buf = (struct smb_hdr *) mempool_alloc(cifs_req_poolp, >+ GFP_KERNEL | GFP_NOFS); >+- >++#else >++ ret_buf = (struct smb_hdr *) kmem_cache_alloc(cifs_req_cachep, >++ SLAB_KERNEL); >++#endif >+ /* clear the first few header bytes */ >+ /* for most paths, more is cleared in header_assemble */ >+ if (ret_buf) { >+@@ -174,7 +186,11 @@ cifs_buf_release(void *buf_to_free) >+ /* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/ >+ return; >+ } >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ mempool_free(buf_to_free, cifs_req_poolp); >++#else >++ kmem_cache_free(cifs_req_cachep, buf_to_free); >++#endif >+ >+ atomic_dec(&bufAllocCount); >+ return; >+@@ -189,8 +205,13 @@ cifs_small_buf_get(void) >+ but it may be more efficient to always alloc same size >+ albeit slightly larger than necessary and maxbuffersize >+ defaults to this and can not be bigger */ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ ret_buf = (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, >+ GFP_KERNEL | GFP_NOFS); >++#else >++ ret_buf = (struct smb_hdr *) kmem_cache_alloc(cifs_sm_req_cachep, >++ SLAB_KERNEL); >++#endif >+ if (ret_buf) { >+ /* No need to clear memory here, cleared in header assemble */ >+ /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/ >+@@ -211,7 +232,11 @@ cifs_small_buf_release(void *buf_to_free >+ cFYI(1, ("Null buffer passed to cifs_small_buf_release")); >+ return; >+ } >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) >+ mempool_free(buf_to_free, cifs_sm_req_poolp); >++#else >++ kmem_cache_free(cifs_sm_req_cachep, buf_to_free); >++#endif >+ >+ atomic_dec(&smBufAllocCount); >+ return; >+diff -up linux-2.6.23.i386/fs/cifs/link.c.pre150c linux-2.6.23.i386/fs/cifs/link.c >+--- linux-2.6.23.i386/fs/cifs/link.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/link.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -20,7 +20,10 @@ >+ */ >+ #include <linux/fs.h> >+ #include <linux/stat.h> >++#include <linux/version.h> >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) >+ #include <linux/namei.h> >++#endif >+ #include "cifsfs.h" >+ #include "cifspdu.h" >+ #include "cifsglob.h" >+@@ -102,9 +105,13 @@ cifs_hl_exit: >+ FreeXid(xid); >+ return rc; >+ } >+- >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) >+ void * >+ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) >++#else >++int >++cifs_follow_link(struct dentry *direntry, struct nameidata *nd) >++#endif >+ { >+ struct inode *inode = direntry->d_inode; >+ int rc = -EACCES; >+@@ -153,6 +160,9 @@ cifs_follow_link(struct dentry *direntry >+ /* BB Add special case check for Samba DFS symlinks */ >+ >+ target_path[PATH_MAX-1] = 0; >++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) >++ rc = vfs_follow_link(nd, target_path); >++#endif >+ } else { >+ kfree(target_path); >+ target_path = ERR_PTR(rc); >+@@ -162,8 +172,14 @@ out: >+ kfree(full_path); >+ out_no_free: >+ FreeXid(xid); >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) >+ nd_set_link(nd, target_path); >++#endif >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) >+ return NULL; /* No cookie */ >++#else >++ return 0; >++#endif >+ } >+ >+ int >+@@ -237,7 +253,7 @@ cifs_readlink(struct dentry *direntry, c >+ char *tmp_path = NULL; >+ char *tmpbuffer; >+ unsigned char *referrals = NULL; >+- int num_referrals = 0; >++ unsigned int num_referrals = 0; >+ int len; >+ __u16 fid; >+ >+@@ -353,9 +369,15 @@ cifs_readlink(struct dentry *direntry, c >+ return rc; >+ } >+ >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12) >+ void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie) >++#else >++void cifs_put_link(struct dentry *direntry, struct nameidata *nd) >++#endif >+ { >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) >+ char *p = nd_get_link(nd); >+ if (!IS_ERR(p)) >+ kfree(p); >++#endif >+ } >+diff -up linux-2.6.23.i386/fs/cifs/ioctl.c.pre150c linux-2.6.23.i386/fs/cifs/ioctl.c >+--- linux-2.6.23.i386/fs/cifs/ioctl.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/ioctl.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -29,6 +29,15 @@ >+ #include "cifsfs.h" >+ >+ #define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) >++#ifndef FS_IOC_GETFLAGS >++#define FS_IOC_GETFLAGS _IOR('f', 1, long) >++#endif >++#ifndef FS_IOC_SETFLAGS >++#define FS_IOC_SETFLAGS _IOW('f', 2, long) >++#endif >++#ifndef FS_FL_USER_VISIBLE >++#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */ >++#endif >+ >+ int cifs_ioctl (struct inode *inode, struct file *filep, >+ unsigned int command, unsigned long arg) >+diff -up linux-2.6.23.i386/fs/cifs/cifspdu.h.pre150c linux-2.6.23.i386/fs/cifs/cifspdu.h >+--- linux-2.6.23.i386/fs/cifs/cifspdu.h.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/cifspdu.h 2008-01-09 17:40:28.000000000 +0100 >+@@ -101,6 +101,15 @@ >+ ***************************************************************** >+ */ >+ >++#ifndef __le16 >++#define __le16 __u16 >++#define __le32 __u32 >++#define __le64 __u64 >++#define __be16 __u16 >++#define __be32 __u32 >++#define __be64 __u64 >++#endif >++ >+ /* >+ * Starting value for maximum SMB size negotiation >+ */ >+diff -up linux-2.6.23.i386/fs/cifs/export.c.pre150c linux-2.6.23.i386/fs/cifs/export.c >+--- linux-2.6.23.i386/fs/cifs/export.c.pre150c 2008-01-09 17:40:19.000000000 +0100 >++++ linux-2.6.23.i386/fs/cifs/export.c 2008-01-09 17:40:28.000000000 +0100 >+@@ -40,11 +40,15 @@ >+ */ >+ >+ #include <linux/fs.h> >+-#include <linux/exportfs.h> >+ #include "cifsglob.h" >+ #include "cifs_debug.h" >++#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22) >++#include <linux/exportfs.h> >++#endif >++ >+ >+ #ifdef CONFIG_CIFS_EXPERIMENTAL >++ >+ static struct dentry *cifs_get_parent(struct dentry *dentry) >+ { >+ /* BB need to add code here eventually to enable export via NFSD */ >diff -r -Nu kernel-2.6.23.12-52.fc7/kernel-2.6.spec kernel-2.6.23.12-52.bug247204.fc7/kernel-2.6.spec >--- kernel-2.6.23.12-52.fc7/kernel-2.6.spec 2007-12-19 01:43:37.000000000 +0100 >+++ kernel-2.6.23.12-52.bug247204.fc7/kernel-2.6.spec 2008-01-09 18:00:45.000000000 +0100 >@@ -12,7 +12,7 @@ > # that the kernel isn't the stock distribution kernel, for example, > # by setting the define to ".local" or ".bz123456" > # >-#% define buildid .local >+%define buildid .bug247204 > > # fedora_build defines which build revision of this kernel version we're > # building. Rather than incrementing forever, as with the prior versioning >@@ -653,6 +653,8 @@ > > Patch2300: linux-2.6-freezer-fix-apm-emulation-breakage.patch > >+Patch2999: cifs-150c-plus.patch >+ > %endif > > BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root-%{_target_cpu} >@@ -1224,6 +1226,7 @@ > ApplyPatch linux-2.6-cifs-fix-bad-handling-of-EAGAIN.patch > # fix oops mounting filesystem a second time > ApplyPatch linux-2.6-cifs-fix-oops-on-second-mount.patch >+ApplyPatch cifs-150c-plus.patch > > # Networking > # Disable easy to trigger printk's.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247204
:
158793
|
158794
|
158978
|
201661
| 291263