diff -urN linux-2.4.22.org/fs/nfs/dir.c linux-2.4.22/fs/nfs/dir.c --- linux-2.4.22.org/fs/nfs/dir.c 2003-11-21 19:45:07.000000000 +0100 +++ linux-2.4.22/fs/nfs/dir.c 2003-11-21 19:52:27.000000000 +0100 @@ -34,6 +34,7 @@ #define NFS_PARANOIA 1 /* #define NFS_DEBUG_VERBOSE 1 */ +static loff_t nfs_dir_llseek(struct file *, loff_t, int); static int nfs_readdir(struct file *, void *, filldir_t); static struct dentry *nfs_lookup(struct inode *, struct dentry *); static int nfs_create(struct inode *, struct dentry *, int); @@ -48,6 +49,7 @@ static int nfs_fsync_dir(struct file *, struct dentry *, int); struct file_operations nfs_dir_operations = { + llseek: nfs_dir_llseek, read: generic_read_dir, readdir: nfs_readdir, open: nfs_open, @@ -74,6 +76,25 @@ removexattr: nfs_removexattr, }; +static loff_t nfs_dir_llseek(struct file *file, loff_t offset, int origin) +{ + switch (origin) { + case 1: + if (offset == 0) { + offset = file->f_pos; + break; + } + case 2: + return -EINVAL; + } + if (offset != file->f_pos) { + file->f_pos = offset; + file->f_reada = 0; + file->f_version = ++event; + } + return (offset <= 0) ? 0 : offset; +} + typedef u32 * (*decode_dirent_t)(u32 *, struct nfs_entry *, int); typedef struct { struct file *file; diff -urN linux-2.4.22.org/fs/nfs/nfs2xdr.c linux-2.4.22/fs/nfs/nfs2xdr.c --- linux-2.4.22.org/fs/nfs/nfs2xdr.c 2003-11-21 19:45:07.000000000 +0100 +++ linux-2.4.22/fs/nfs/nfs2xdr.c 2003-11-21 19:52:27.000000000 +0100 @@ -369,7 +369,7 @@ count = count >> 2; p = xdr_encode_fhandle(p, args->fh); - *p++ = htonl(args->cookie); + *p++ = htonl(args->cookie & 0xFFFFFFFF); *p++ = htonl(count); /* see above */ req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); @@ -466,7 +466,7 @@ entry->name = (const char *) p; p += XDR_QUADLEN(entry->len); entry->prev_cookie = entry->cookie; - entry->cookie = ntohl(*p++); + entry->cookie = (s64)((off_t)ntohl(*p++)); entry->eof = !p[0] && p[1]; return p; diff -urN linux-2.4.22.org/fs/nfs/nfs3xdr.c linux-2.4.22/fs/nfs/nfs3xdr.c --- linux-2.4.22.org/fs/nfs/nfs3xdr.c 2003-11-21 19:45:07.000000000 +0100 +++ linux-2.4.22/fs/nfs/nfs3xdr.c 2003-11-21 19:52:52.000000000 +0100 @@ -471,6 +471,13 @@ return 0; } +/* Hack to sign-extending 32-bit cookies */ +static inline +u64 nfs_transform_cookie64(u64 cookie) +{ + return (cookie & 0x80000000) ? (cookie ^ 0xFFFFFFFF00000000) : cookie; +} + /* * Encode arguments to readdir call */ @@ -482,7 +489,7 @@ u32 count = args->count; p = xdr_encode_fhandle(p, args->fh); - p = xdr_encode_hyper(p, args->cookie); + p = xdr_encode_hyper(p, nfs_transform_cookie64(args->cookie)); *p++ = args->verf[0]; *p++ = args->verf[1]; if (args->plus) { @@ -605,6 +612,8 @@ u32 * nfs3_decode_dirent(u32 *p, struct nfs_entry *entry, int plus) { + u64 cookie; + if (!*p++) { if (!*p) return ERR_PTR(-EAGAIN); @@ -617,7 +626,8 @@ entry->name = (const char *) p; p += XDR_QUADLEN(entry->len); entry->prev_cookie = entry->cookie; - p = xdr_decode_hyper(p, &entry->cookie); + p = xdr_decode_hyper(p, &cookie); + entry->cookie = nfs_transform_cookie64(cookie); if (plus) { struct nfs_fattr fattr;