Commit 73f103e4 authored by Linus Torvalds's avatar Linus Torvalds

Import 2.1.61

parent be6cc637
......@@ -215,7 +215,7 @@ S: Fremont, California 94539
S: USA
N: Gordon Chaffee
E: chaffee@bmrc.berkeley.edu
E: chaffee@cs.berkeley.edu
W: http://bmrc.berkeley.edu/people/chaffee/
D: vfat, fat32, joliet, native language support
S: 3674 Oakwood Terrace #201
......
......@@ -368,9 +368,9 @@ S: Maintained
VFAT FILESYSTEM:
P: Gordon Chaffee
M: chaffee@plateau.cs.berkeley.edu
M: chaffee@cs.berkeley.edu
L: linux-kernel@vger.rutgers.edu
W: http://www-plateau.cs.berkeley.edu/people/chaffee
W: http://bmrc.berkeley.edu/people/chaffee
S: Maintained
DIGI INTL. EPCA DRIVER:
......
VERSION = 2
PATCHLEVEL = 1
SUBLEVEL = 60
SUBLEVEL = 61
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/)
......
......@@ -198,10 +198,12 @@ CONFIG_EEXPRESS_PRO100=y
# CONFIG_QUOTA is not set
# CONFIG_MINIX_FS is not set
CONFIG_EXT2_FS=y
CONFIG_ISO9660_FS=y
# CONFIG_JOLIET is not set
# CONFIG_FAT_FS is not set
# CONFIG_MSDOS_FS is not set
# CONFIG_VFAT_FS is not set
# CONFIG_UMSDOS_FS is not set
# CONFIG_VFAT_FS is not set
CONFIG_PROC_FS=y
CONFIG_NFS_FS=y
# CONFIG_ROOT_NFS is not set
......@@ -209,7 +211,6 @@ CONFIG_NFS_FS=y
CONFIG_SUNRPC=y
CONFIG_LOCKD=y
# CONFIG_SMB_FS is not set
CONFIG_ISO9660_FS=y
# CONFIG_HPFS_FS is not set
# CONFIG_SYSV_FS is not set
# CONFIG_AFFS_FS is not set
......@@ -218,6 +219,11 @@ CONFIG_AUTOFS_FS=y
# CONFIG_UFS_FS is not set
# CONFIG_MAC_PARTITION is not set
#
# Native Language Support
#
# CONFIG_NLS is not set
#
# Character devices
#
......
......@@ -10,19 +10,16 @@ tristate 'Minix fs support' CONFIG_MINIX_FS
tristate 'Second extended fs support' CONFIG_EXT2_FS
tristate 'ISO9660 cdrom filesystem support' CONFIG_ISO9660_FS
tristate 'Native language support (Unicode, codepages)' CONFIG_NLS
if [ "$CONFIG_NLS" = "y" -o "$CONFIG_NLS" = "m" ]; then
if [ "$CONFIG_ISO9660_FS" = "y" -o "$CONFIG_ISO9660_FS" = "m" ]; then
bool 'Microsoft Joliet cdrom extensions' CONFIG_JOLIET
fi
# msdos filesystems
dep_tristate 'DOS FAT fs support' CONFIG_FAT_FS $CONFIG_NLS
dep_tristate 'MSDOS fs support' CONFIG_MSDOS_FS $CONFIG_FAT_FS
dep_tristate 'umsdos: Unix like fs on top of std MSDOS FAT fs' CONFIG_UMSDOS_FS $CONFIG_MSDOS_FS
dep_tristate 'VFAT (Windows-95) fs support' CONFIG_VFAT_FS $CONFIG_FAT_FS
if [ "$CONFIG_ISO9660_FS" != "n" ]; then
bool 'Microsoft Joliet cdrom extensions' CONFIG_JOLIET
fi
# msdos filesystems
tristate 'DOS FAT fs support' CONFIG_FAT_FS
dep_tristate 'MSDOS fs support' CONFIG_MSDOS_FS $CONFIG_FAT_FS
dep_tristate 'umsdos: Unix like fs on top of std MSDOS FAT fs' CONFIG_UMSDOS_FS $CONFIG_MSDOS_FS
dep_tristate 'VFAT (Windows-95) fs support' CONFIG_VFAT_FS $CONFIG_FAT_FS
bool '/proc filesystem support' CONFIG_PROC_FS
if [ "$CONFIG_INET" = "y" ]; then
tristate 'NFS filesystem support' CONFIG_NFS_FS
......
......@@ -100,7 +100,7 @@ static int autofs_root_readdir(struct file *filp, void *dirent, filldir_t filldi
return 0;
}
static int try_to_fill_dentry(struct dentry * dentry, struct super_block * sb, struct autofs_sb_info *sbi)
static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, struct autofs_sb_info *sbi)
{
struct inode * inode;
struct autofs_dir_ent *ent;
......@@ -132,9 +132,10 @@ static int try_to_fill_dentry(struct dentry * dentry, struct super_block * sb, s
dentry->d_inode = inode;
}
if (S_ISDIR(dentry->d_inode->i_mode)) {
while (dentry == dentry->d_mounts)
schedule();
/* If this is a directory that isn't a mount point, bitch at the
daemon and fix it in user space */
if ( S_ISDIR(dentry->d_inode->i_mode) && dentry->d_mounts == dentry ) {
return !autofs_wait(sbi, &dentry->d_name);
}
autofs_update_usage(&sbi->dirhash,ent);
......@@ -159,16 +160,24 @@ static int autofs_revalidate(struct dentry * dentry)
sbi = (struct autofs_sb_info *) dir->i_sb->u.generic_sbp;
/* Pending dentry */
if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
if ( dentry->d_flags & DCACHE_AUTOFS_PENDING ) {
if (autofs_oz_mode(sbi))
return 1;
return try_to_fill_dentry(dentry, dir->i_sb, sbi);
else
return try_to_fill_dentry(dentry, dir->i_sb, sbi);
}
/* Negative dentry.. invalidate if "old" */
if (!dentry->d_inode)
return (dentry->d_time - jiffies <= AUTOFS_NEGATIVE_TIMEOUT);
/* Check for a non-mountpoint directory */
if ( S_ISDIR(dentry->d_inode->i_mode) && dentry->d_mounts == dentry ) {
if (autofs_oz_mode(sbi))
return 1;
else
return try_to_fill_dentry(dentry, dir->i_sb, sbi);
}
/* Update the usage list */
ent = (struct autofs_dir_ent *) dentry->d_time;
......@@ -177,7 +186,7 @@ static int autofs_revalidate(struct dentry * dentry)
}
static struct dentry_operations autofs_dentry_operations = {
autofs_revalidate,
autofs_revalidate, /* d_revalidate */
NULL, /* d_hash */
NULL, /* d_compare */
};
......
......@@ -465,12 +465,13 @@ static inline struct list_head * d_hash(struct dentry * parent, unsigned long ha
return dentry_hashtable + (hash & D_HASHMASK);
}
static inline struct dentry * __dlookup(struct list_head *head, struct dentry * parent, struct qstr * name)
struct dentry * d_lookup(struct dentry * parent, struct qstr * name)
{
struct list_head *tmp = head->next;
int len = name->len;
int hash = name->hash;
unsigned int len = name->len;
unsigned int hash = name->hash;
const unsigned char *str = name->name;
struct list_head *head = d_hash(parent,hash);
struct list_head *tmp = head->next;
while (tmp != head) {
struct dentry * dentry = list_entry(tmp, struct dentry, d_hash);
......@@ -489,16 +490,11 @@ static inline struct dentry * __dlookup(struct list_head *head, struct dentry *
if (memcmp(dentry->d_name.name, str, len))
continue;
}
return dget(dentry->d_mounts);
return dget(dentry);
}
return NULL;
}
struct dentry * d_lookup(struct dentry * dir, struct qstr * name)
{
return __dlookup(d_hash(dir, name->hash), dir, name);
}
/*
* An insecure source has sent us a dentry, here we verify it.
*
......
......@@ -20,6 +20,7 @@
#include <linux/malloc.h>
#include <linux/sched.h>
#include <linux/locks.h>
#include <linux/config.h>
#include <asm/uaccess.h>
......@@ -206,10 +207,13 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
}
}
#ifdef CONFIG_JOLIET
if (inode->i_sb->u.isofs_sb.s_joliet_level) {
len = get_joliet_filename(de, inode, tmpname);
p = tmpname;
} else {
} else
#endif
/* if not joliet */ {
map = 1;
if (inode->i_sb->u.isofs_sb.s_rock) {
len = get_rock_ridge_filename(de, tmpname, inode);
......
......@@ -89,8 +89,7 @@ struct iso9660_options{
static int parse_options(char *options, struct iso9660_options * popt)
{
char *this_char,*value,*p;
int len;
char *this_char,*value;
popt->map = 'n';
popt->rock = 'y';
......@@ -135,6 +134,9 @@ static int parse_options(char *options, struct iso9660_options * popt)
#ifdef CONFIG_JOLIET
if (!strcmp(this_char,"iocharset")) {
char *p;
int len;
p = value;
while (*value && *value != ',') value++;
len = value - p;
......@@ -275,7 +277,6 @@ struct super_block *isofs_read_super(struct super_block *s,void *data,
int joliet_level = 0;
struct iso9660_options opt;
int orig_zonesize;
char * p;
struct iso_primary_descriptor * pri = NULL;
struct iso_directory_record * rootp;
struct iso_supplementary_descriptor *sec = NULL;
......@@ -413,8 +414,10 @@ struct super_block *isofs_read_super(struct super_block *s,void *data,
MOD_DEC_USE_COUNT;
return NULL;
}
#ifdef CONFIG_JOLIET
s->u.isofs_sb.s_joliet_level = joliet_level;
#ifdef CONFIG_JOLIET
if (joliet_level) {
/* Note: In theory, it is possible to have Rock Ridge
* extensions mixed with Joliet. All character strings
......@@ -549,6 +552,7 @@ struct super_block *isofs_read_super(struct super_block *s,void *data,
opt.iocharset = NULL;
}
} else if (opt.utf8 == 0) {
char * p;
p = opt.iocharset ? opt.iocharset : "iso8859-1";
s->u.isofs_sb.s_nls_iocharset = load_nls(p);
if (! s->u.isofs_sb.s_nls_iocharset) {
......
......@@ -237,8 +237,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name)
int error = dir->i_op->lookup(dir, dentry);
result = ERR_PTR(error);
if (!error)
result = dget(dentry->d_mounts);
dput(dentry);
result = dentry;
}
}
up(&dir->i_sem);
......@@ -293,25 +292,6 @@ static struct dentry * reserved_lookup(struct dentry * parent, struct qstr * nam
return dget(result);
}
/* In difference to the former version, lookup() no longer eats the dir. */
static inline struct dentry * lookup(struct dentry * dir, struct qstr * name)
{
struct dentry * result;
result = reserved_lookup(dir, name);
if (result)
goto done;
result = cached_lookup(dir, name);
if (result)
goto done;
result = real_lookup(dir, name);
done:
return result;
}
static struct dentry * do_follow_link(struct dentry *base, struct dentry *dentry)
{
struct inode * inode = dentry->d_inode;
......@@ -334,6 +314,18 @@ static struct dentry * do_follow_link(struct dentry *base, struct dentry *dentry
return dentry;
}
static inline struct dentry * follow_mount(struct dentry * dentry)
{
struct dentry * mnt = dentry->d_mounts;
if (mnt != dentry) {
dget(mnt);
dput(dentry);
dentry = mnt;
}
return dentry;
}
/*
* Name resolution.
*
......@@ -415,9 +407,19 @@ struct dentry * lookup_dentry(const char * name, struct dentry * base, int follo
}
}
dentry = lookup(base, &this);
if (IS_ERR(dentry))
break;
/* This does the actual lookups.. */
dentry = reserved_lookup(base, &this);
if (!dentry) {
dentry = cached_lookup(base, &this);
if (!dentry) {
dentry = real_lookup(base, &this);
if (IS_ERR(dentry))
break;
}
}
/* Check mountpoints.. */
dentry = follow_mount(dentry);
if (!follow)
break;
......
This diff is collapsed.
......@@ -83,53 +83,77 @@ struct inode_operations nfs_file_inode_operations = {
# define IS_SWAPFILE(inode) (0)
#endif
/*
* Flush all dirty pages, and check for write errors.
*
* Note that since the file close operation is called only by the
* _last_ process to close the file, we need to flush _all_ dirty
* pages. This also means that there is little sense in checking
* for errors for this specific process -- we should probably just
* clear all errors.
*/
static int
nfs_file_close(struct inode *inode, struct file *file)
{
int status;
int status, error;
dfprintk(VFS, "nfs: close(%x/%ld)\n", inode->i_dev, inode->i_ino);
if ((status = nfs_flush_dirty_pages(inode, 0, 0)) < 0)
return status;
return nfs_write_error(inode);
status = nfs_flush_dirty_pages(inode, 0, 0, 0);
error = nfs_write_error(inode);
if (!status)
status = error;
return status;
}
static ssize_t
nfs_file_read(struct file * file, char * buf, size_t count, loff_t *ppos)
{
struct inode * inode = file->f_dentry->d_inode;
int status;
ssize_t result;
dfprintk(VFS, "nfs: read(%x/%ld, %lu@%lu)\n",
inode->i_dev, inode->i_ino, count,
(unsigned long) *ppos);
if ((status = nfs_revalidate_inode(NFS_SERVER(inode), inode)) < 0)
return status;
return generic_file_read(file, buf, count, ppos);
result = nfs_revalidate_inode(NFS_SERVER(inode), inode);
if (!result)
result = generic_file_read(file, buf, count, ppos);
return result;
}
static int
nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
{
int status;
struct inode *inode = file->f_dentry->d_inode;
int status;
dfprintk(VFS, "nfs: mmap(%x/%ld)\n", inode->i_dev, inode->i_ino);
if ((status = nfs_revalidate_inode(NFS_SERVER(inode), inode)) < 0)
return status;
return generic_file_mmap(file, vma);
status = nfs_revalidate_inode(NFS_SERVER(inode), inode);
if (!status)
status = generic_file_mmap(file, vma);
return status;
}
static int nfs_fsync(struct file *file, struct dentry *dentry)
/*
* Flush any dirty pages for this process, and check for write errors.
* The return status from this call provides a reliable indication of
* whether any write errors occurred for this process.
*/
static int
nfs_fsync(struct file *file, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
int status, error;
dfprintk(VFS, "nfs: fsync(%x/%ld)\n", inode->i_dev, inode->i_ino);
return nfs_flush_dirty_pages(inode, 0, 0);
status = nfs_flush_dirty_pages(inode, current->pid, 0, 0);
error = nfs_write_error(inode);
if (!status)
status = error;
return status;
}
/*
......@@ -139,7 +163,7 @@ static ssize_t
nfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
struct inode * inode = file->f_dentry->d_inode;
int result;
ssize_t result;
dfprintk(VFS, "nfs: write(%x/%ld (%d), %lu@%lu)\n",
inode->i_dev, inode->i_ino, inode->i_count,
......@@ -153,21 +177,26 @@ nfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
printk("NFS: attempt to write to active swap file!\n");
return -EBUSY;
}
if ((result = nfs_revalidate_inode(NFS_SERVER(inode), inode)) < 0)
return result;
result = nfs_revalidate_inode(NFS_SERVER(inode), inode);
if (result)
goto out;
/* N.B. This should be impossible now -- inodes can't change mode */
if (!S_ISREG(inode->i_mode)) {
printk("nfs_file_write: write to non-file, mode %07o\n",
inode->i_mode);
return -EINVAL;
}
if (count <= 0)
return 0;
/* Return error from previous async call */
if ((result = nfs_write_error(inode)) < 0)
return result;
return generic_file_write(file, buf, count, ppos);
result = count;
if (!count)
goto out;
/* Check for an error from a previous async call */
result = nfs_write_error(inode);
if (!result)
result = generic_file_write(file, buf, count, ppos);
out:
return result;
}
/*
......@@ -176,15 +205,15 @@ nfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
int
nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
{
struct inode * inode = filp->f_dentry->d_inode;
int status;
struct inode * inode;
dprintk("NFS: nfs_lock(f=%4x/%ld, t=%x, fl=%x, r=%ld:%ld)\n",
filp->f_dentry->d_inode->i_dev, filp->f_dentry->d_inode->i_ino,
inode->i_dev, inode->i_ino,
fl->fl_type, fl->fl_flags,
fl->fl_start, fl->fl_end);
if (!(inode = filp->f_dentry->d_inode))
if (!inode)
return -EINVAL;
/* No mandatory locks over NFS */
......@@ -209,7 +238,7 @@ nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
* been killed by a signal, that is). */
if (cmd == F_SETLK && fl->fl_type == F_UNLCK
&& !signal_pending(current)) {
status = nfs_flush_dirty_pages(inode,
status = nfs_flush_dirty_pages(inode, current->pid,
fl->fl_start, fl->fl_end == NLM_OFFSET_MAX? 0 :
fl->fl_end - fl->fl_start + 1);
if (status < 0)
......
......@@ -91,16 +91,19 @@ nfs_put_inode(struct inode * inode)
static void
nfs_delete_inode(struct inode * inode)
{
int failed;
dprintk("NFS: delete_inode(%x/%ld)\n", inode->i_dev, inode->i_ino);
/*
* Flush out any pending write requests ...
*/
if (NFS_WRITEBACK(inode) != NULL) {
unsigned long timeout = jiffies + 5*HZ;
printk("NFS: invalidating pending RPC requests\n");
printk("NFS: inode %ld, invalidating pending RPC requests\n",
inode->i_ino);
nfs_invalidate_pages(inode);
while (NFS_WRITEBACK(inode) != NULL && jiffies < timeout) {
current->state = TASK_UNINTERRUPTIBLE;
current->state = TASK_INTERRUPTIBLE;
current->timeout = jiffies + HZ/10;
schedule();
}
......@@ -109,8 +112,10 @@ nfs_delete_inode(struct inode * inode)
printk("NFS: Arghhh, stuck RPC requests!\n");
}
if (check_failed_request(inode))
printk("NFS: inode had failed requests\n");
failed = check_failed_request(inode);
if (failed)
printk("NFS: inode %ld had %d failed requests\n",
inode->i_ino, failed);
clear_inode(inode);
}
......
......@@ -286,16 +286,17 @@ find_write_request(struct inode *inode, struct page *page)
* Find a failed write request by pid
*/
static struct nfs_wreq *
find_failed_request(struct inode *inode, pid_t pid, int all)
find_failed_request(struct inode *inode, pid_t pid)
{
struct nfs_wreq *head, *req;
if (!(req = head = nfs_failed_requests))
return NULL;
do {
if (req->wb_inode == inode && (all || req->wb_pid == pid))
req = head = nfs_failed_requests;
while (req != NULL) {
if (req->wb_inode == inode && (pid == 0 || req->wb_pid == pid))
return req;
} while ((req = WB_NEXT(req)) != head);
if ((req = WB_NEXT(req)) == head)
break;
}
return NULL;
}
......@@ -335,7 +336,7 @@ check_failed_request(struct inode * inode)
struct nfs_wreq * req;
int found = 0;
while ((req = find_failed_request(inode, 0, 1)) != NULL) {
while ((req = find_failed_request(inode, 0)) != NULL) {
remove_failed_request(req);
found++;
}
......@@ -561,12 +562,13 @@ nfs_updatepage(struct inode *inode, struct page *page, const char *buffer,
}
/* Create the write request. */
if (!(req = create_write_request(inode, page, offset, count))) {
status = -ENOBUFS;
status = -ENOBUFS;
req = create_write_request(inode, page, offset, count);
if (!req)
goto done;
}
/* Copy data to page buffer. */
/* N.B. should check for fault here ... */
copy_from_user(page_addr + offset, buffer, count);
/* Schedule request */
......@@ -593,6 +595,7 @@ nfs_updatepage(struct inode *inode, struct page *page, const char *buffer,
transfer_page_lock(req);
/* rpc_execute(&req->wb_task); */
if (sync) {
/* N.B. if signalled, result not ready? */
wait_on_write_request(req);
if ((count = nfs_write_error(inode)) < 0)
status = count;
......@@ -652,10 +655,20 @@ nfs_flush_pages(struct inode *inode, pid_t pid, off_t offset, off_t len,
if (rqoffset < end && offset < rqend
&& (pid == 0 || req->wb_pid == pid)) {
if (!WB_HAVELOCK(req))
if (!WB_HAVELOCK(req)) {
#ifdef NFS_PARANOIA
printk("nfs_flush: flushing inode=%ld, %d @ %lu\n",
req->wb_inode->i_ino, req->wb_bytes, rqoffset);
#endif
nfs_flush_request(req);
}
last = req;
}
} else {
#ifdef NFS_PARANOIA
printk("nfs_flush_pages: in progress inode=%ld, %d @ %lu\n",
req->wb_inode->i_ino, req->wb_bytes, rqoffset);
#endif
}
if (invalidate)
req->wb_flags |= NFS_WRITE_INVALIDATE;
......@@ -668,6 +681,10 @@ nfs_flush_pages(struct inode *inode, pid_t pid, off_t offset, off_t len,
/*
* Cancel all writeback requests, both pending and in progress.
*
* N.B. This doesn't seem to wake up the tasks -- are we sure
* they will eventually complete? Also, this could overwrite a
* failed status code from an already-completed task.
*/
static void
nfs_cancel_dirty(struct inode *inode, pid_t pid)
......@@ -676,7 +693,8 @@ nfs_cancel_dirty(struct inode *inode, pid_t pid)
req = head = NFS_WRITEBACK(inode);
while (req != NULL) {
if (req->wb_pid == pid) {
/* N.B. check for task already finished? */
if (pid == 0 || req->wb_pid == pid) {
req->wb_flags |= NFS_WRITE_CANCELLED;
rpc_exit(&req->wb_task, 0);
}
......@@ -694,24 +712,30 @@ nfs_cancel_dirty(struct inode *inode, pid_t pid)
* this isn't used by the nlm module yet.
*/
int
nfs_flush_dirty_pages(struct inode *inode, off_t offset, off_t len)
nfs_flush_dirty_pages(struct inode *inode, pid_t pid, off_t offset, off_t len)
{
struct nfs_wreq *last = NULL;
int result = 0;
int result = 0, cancel = 0;
dprintk("NFS: flush_dirty_pages(%x/%ld for pid %d %ld/%ld)\n",
inode->i_dev, inode->i_ino, current->pid,
offset, len);
if (IS_SOFT && signalled()) {
nfs_cancel_dirty(inode, pid);
cancel = 1;
}
for (;;) {
if (IS_SOFT && signalled()) {
nfs_cancel_dirty(inode, current->pid);
if (!cancel)
nfs_cancel_dirty(inode, pid);
result = -ERESTARTSYS;
break;
}
/* Flush all pending writes for this pid and file region */
last = nfs_flush_pages(inode, current->pid, offset, len, 0);
/* Flush all pending writes for the pid and file region */
last = nfs_flush_pages(inode, pid, offset, len, 0);
if (last == NULL)
break;
wait_on_write_request(last);
......@@ -724,7 +748,7 @@ nfs_flush_dirty_pages(struct inode *inode, off_t offset, off_t len)
* Flush out any pending write requests and flag that they be discarded
* after the write is complete.
*
* This function is called from nfs_revalidate_inode just before it calls
* This function is called from nfs_refresh_inode just before it calls
* invalidate_inode_pages. After nfs_flush_pages returns, we can be sure
* that all dirty pages are locked, so that invalidate_inode_pages does
* not throw away any dirty pages.
......@@ -780,7 +804,7 @@ nfs_check_error(struct inode *inode)
dprintk("nfs: checking for write error inode %04x/%ld\n",
inode->i_dev, inode->i_ino);
req = find_failed_request(inode, current->pid, 0);
req = find_failed_request(inode, current->pid);
if (req) {
dprintk("nfs: write error %d inode %04x/%ld\n",
req->wb_task.tk_status, inode->i_dev, inode->i_ino);
......@@ -869,7 +893,7 @@ nfs_wback_result(struct rpc_task *task)
* application by adding the request to the failed
* requests list.
*/
if (find_failed_request(inode, req->wb_pid, 0))
if (find_failed_request(inode, req->wb_pid))
status = 0;
clear_bit(PG_uptodate, &page->flags);
} else if (!WB_CANCELLED(req)) {
......
......@@ -5,35 +5,40 @@
mainmenu_option next_comment
comment 'Native Language Support'
tristate 'Native language support (Unicode, codepages)' CONFIG_NLS
# msdos and Joliet want NLS
if [ "$CONFIG_JOLIET" = "y" -o "$CONFIG_FAT_FS" != "n" ]; then
define_bool CONFIG_NLS y
else
define_bool CONFIG_NLS n
fi
if [ "$CONFIG_NLS" = "y" -o "$CONFIG_NLS" = "m" ]; then
dep_tristate 'Codepage 437' CONFIG_NLS_CODEPAGE_437 $CONFIG_NLS
dep_tristate 'Codepage 737' CONFIG_NLS_CODEPAGE_737 $CONFIG_NLS
dep_tristate 'Codepage 775' CONFIG_NLS_CODEPAGE_775 $CONFIG_NLS
dep_tristate 'Codepage 850' CONFIG_NLS_CODEPAGE_850 $CONFIG_NLS
dep_tristate 'Codepage 852' CONFIG_NLS_CODEPAGE_852 $CONFIG_NLS
dep_tristate 'Codepage 855' CONFIG_NLS_CODEPAGE_855 $CONFIG_NLS
dep_tristate 'Codepage 857' CONFIG_NLS_CODEPAGE_857 $CONFIG_NLS
dep_tristate 'Codepage 860' CONFIG_NLS_CODEPAGE_860 $CONFIG_NLS
dep_tristate 'Codepage 861' CONFIG_NLS_CODEPAGE_861 $CONFIG_NLS
dep_tristate 'Codepage 862' CONFIG_NLS_CODEPAGE_862 $CONFIG_NLS
dep_tristate 'Codepage 863' CONFIG_NLS_CODEPAGE_863 $CONFIG_NLS
dep_tristate 'Codepage 864' CONFIG_NLS_CODEPAGE_864 $CONFIG_NLS
dep_tristate 'Codepage 865' CONFIG_NLS_CODEPAGE_865 $CONFIG_NLS
dep_tristate 'Codepage 866' CONFIG_NLS_CODEPAGE_866 $CONFIG_NLS
dep_tristate 'Codepage 869' CONFIG_NLS_CODEPAGE_869 $CONFIG_NLS
dep_tristate 'Codepage 874' CONFIG_NLS_CODEPAGE_874 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-1' CONFIG_NLS_ISO8859_1 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-2' CONFIG_NLS_ISO8859_2 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-3' CONFIG_NLS_ISO8859_3 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-4' CONFIG_NLS_ISO8859_4 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-5' CONFIG_NLS_ISO8859_5 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-6' CONFIG_NLS_ISO8859_6 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-7' CONFIG_NLS_ISO8859_7 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-8' CONFIG_NLS_ISO8859_8 $CONFIG_NLS
dep_tristate 'NLS ISO 8859-9' CONFIG_NLS_ISO8859_9 $CONFIG_NLS
dep_tristate 'NLS KOI8-R' CONFIG_NLS_KOI8_R $CONFIG_NLS
if [ "$CONFIG_NLS" = "y" ]; then
tristate 'Codepage 437' CONFIG_NLS_CODEPAGE_437
tristate 'Codepage 737' CONFIG_NLS_CODEPAGE_737
tristate 'Codepage 775' CONFIG_NLS_CODEPAGE_775
tristate 'Codepage 850' CONFIG_NLS_CODEPAGE_850
tristate 'Codepage 852' CONFIG_NLS_CODEPAGE_852
tristate 'Codepage 855' CONFIG_NLS_CODEPAGE_855
tristate 'Codepage 857' CONFIG_NLS_CODEPAGE_857
tristate 'Codepage 860' CONFIG_NLS_CODEPAGE_860
tristate 'Codepage 861' CONFIG_NLS_CODEPAGE_861
tristate 'Codepage 862' CONFIG_NLS_CODEPAGE_862
tristate 'Codepage 863' CONFIG_NLS_CODEPAGE_863
tristate 'Codepage 864' CONFIG_NLS_CODEPAGE_864
tristate 'Codepage 865' CONFIG_NLS_CODEPAGE_865
tristate 'Codepage 866' CONFIG_NLS_CODEPAGE_866
tristate 'Codepage 869' CONFIG_NLS_CODEPAGE_869
tristate 'Codepage 874' CONFIG_NLS_CODEPAGE_874
tristate 'NLS ISO 8859-1' CONFIG_NLS_ISO8859_1
tristate 'NLS ISO 8859-2' CONFIG_NLS_ISO8859_2
tristate 'NLS ISO 8859-3' CONFIG_NLS_ISO8859_3
tristate 'NLS ISO 8859-4' CONFIG_NLS_ISO8859_4
tristate 'NLS ISO 8859-5' CONFIG_NLS_ISO8859_5
tristate 'NLS ISO 8859-6' CONFIG_NLS_ISO8859_6
tristate 'NLS ISO 8859-7' CONFIG_NLS_ISO8859_7
tristate 'NLS ISO 8859-8' CONFIG_NLS_ISO8859_8
tristate 'NLS ISO 8859-9' CONFIG_NLS_ISO8859_9
tristate 'NLS KOI8-R' CONFIG_NLS_KOI8_R
fi
endmenu
......@@ -4,15 +4,7 @@
MOD_LIST_NAME := NLS_MODULES
ifeq ($(CONFIG_NLS),y)
NLS += nls_base.o
O_TARGET = nls.o
OX_OBJS = $(NLS)
else
ifeq ($(CONFIG_NLS),m)
MX_OBJS += nls_base.o
endif
endif
NLS = nls_base.o
ifeq ($(CONFIG_NLS_CODEPAGE_437),y)
NLS += nls_cp437.o
......@@ -302,4 +294,7 @@ else
endif
endif
O_TARGET = nls.o
OX_OBJS = $(NLS)
include $(TOPDIR)/Rules.make
......@@ -6,7 +6,6 @@
*
*/
#define ASC_LINUX_VERSION(V, P, S) (((V) * 65536) + ((P) * 256) + (S))
#include <linux/version.h>
#include <linux/module.h>
#include <linux/string.h>
......@@ -479,11 +478,10 @@ int init_nls(void)
#ifdef CONFIG_NLS_CODEPAGE_874
init_nls_cp874();
#endif
#if LINUX_VERSION_CODE >= ASC_LINUX_VERSION(2,1,0)
return 0;
#else
return register_symtab(&nls_syms);
#ifdef CONFIG_NLS_KOI8_R
init_nls_koi8_r();
#endif
return 0;
}
#ifdef MODULE
......
......@@ -130,13 +130,14 @@ printk("smb_init_dircache: initializing cache, %d blocks\n", cachep->pages);
* entries are coming in order and are added to the end.
*/
void
smb_add_to_cache(struct cache_head * cachep, struct dirent *entry, off_t fpos)
smb_add_to_cache(struct cache_head * cachep, struct cache_dirent *entry,
off_t fpos)
{
struct inode * inode = get_cache_inode(cachep);
struct cache_index * index;
struct cache_block * block;
unsigned long page_off;
unsigned int nent, offset, len = entry->d_reclen;
unsigned int nent, offset, len = entry->len;
unsigned int needed = len + sizeof(struct cache_entry);
#ifdef SMBFS_DEBUG_VERBOSE
......@@ -163,10 +164,10 @@ inode, cachep->status, entry->d_name, fpos);
offset = index->space +
index->num_entries * sizeof(struct cache_entry);
block = index->block;
memcpy(&block->cb_data.names[offset], entry->d_name, len);
memcpy(&block->cb_data.names[offset], entry->name, len);
block->cb_data.table[nent].namelen = len;
block->cb_data.table[nent].offset = offset;
block->cb_data.table[nent].ino = entry->d_ino;
block->cb_data.table[nent].ino = entry->ino;
cachep->entries++;
#ifdef SMBFS_DEBUG_VERBOSE
printk("smb_add_to_cache: added entry %s, len=%d, pos=%ld, entries=%d\n",
......
......@@ -8,20 +8,14 @@
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/stat.h>
#include <linux/kernel.h>
#include <linux/malloc.h>
#include <linux/mm.h>
#include <linux/smb_fs.h>
#include <linux/smbno.h>
#include <linux/errno.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
#define SMBFS_PARANOIA 1
/* #define SMBFS_DEBUG_VERBOSE 1 */
/* #define pr_debug printk */
#define SMBFS_MAX_AGE 5*HZ
static ssize_t smb_dir_read(struct file *, char *, size_t, loff_t *);
static int smb_readdir(struct file *, void *, filldir_t);
......@@ -94,13 +88,13 @@ hash_it(const char * name, unsigned int len)
* If a dentry already exists, we have to give the cache entry
* the correct inode number. This is needed for getcwd().
*/
static unsigned long
static void
smb_find_ino(struct dentry *dentry, struct cache_dirent *entry)
{
struct dentry * new_dentry;
struct qstr qname;
unsigned long ino = 0;
/* N.B. Make cache_dirent name a qstr! */
qname.name = entry->name;
qname.len = entry->len;
qname.hash = hash_it(qname.name, qname.len);
......@@ -109,12 +103,11 @@ smb_find_ino(struct dentry *dentry, struct cache_dirent *entry)
{
struct inode * inode = new_dentry->d_inode;
if (inode)
ino = inode->i_ino;
entry->ino = inode->i_ino;
dput(new_dentry);
}
if (!ino)
ino = smb_invent_inos(1);
return ino;
if (!entry->ino)
entry->ino = smb_invent_inos(1);
}
static int
......@@ -125,9 +118,10 @@ smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
struct cache_head *cachep;
int result;
pr_debug("smb_readdir: filp->f_pos = %d\n", (int) filp->f_pos);
pr_debug("smb_readdir: dir->i_ino = %ld, c_ino = %ld\n",
dir->i_ino, c_ino);
#ifdef SMBFS_DEBUG_VERBOSE
printk("smb_readdir: reading %s/%s, f_pos=%d\n",
dentry->d_parent->d_name.name, dentry->d_name.name, (int) filp->f_pos);
#endif
/*
* Make sure our inode is up-to-date.
*/
......@@ -137,6 +131,7 @@ smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
/*
* Get the cache pointer ...
*/
result = -EIO;
cachep = smb_get_dircache(dentry);
if (!cachep)
goto out;
......@@ -147,19 +142,20 @@ smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
result = smb_refill_dircache(cachep, dentry);
if (result)
goto up_and_out;
goto out_free;
}
result = 0;
switch ((unsigned int) filp->f_pos)
{
case 0:
if (filldir(dirent, ".", 1, 0, dir->i_ino) < 0)
goto up_and_out;
goto out_free;
filp->f_pos = 1;
case 1:
if (filldir(dirent, "..", 2, 1,
dentry->d_parent->d_inode->i_ino) < 0)
goto up_and_out;
goto out_free;
filp->f_pos = 2;
}
......@@ -173,21 +169,18 @@ smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
* Check whether to look up the inode number.
*/
if (!entry->ino)
{
entry->ino = smb_find_ino(dentry, entry);
}
smb_find_ino(dentry, entry);
if (filldir(dirent, entry->name, entry->len,
filp->f_pos, entry->ino) < 0)
break;
filp->f_pos += 1;
}
result = 0;
/*
* Release the dircache.
*/
up_and_out:
out_free:
smb_free_dircache(cachep);
out:
return result;
......@@ -220,7 +213,8 @@ static struct dentry_operations smbfs_dentry_operations =
/*
* This is the callback when the dcache has a lookup hit.
*/
static int smb_lookup_validate(struct dentry * dentry)
static int
smb_lookup_validate(struct dentry * dentry)
{
struct inode * inode = dentry->d_inode;
unsigned long age = jiffies - dentry->d_time;
......@@ -231,11 +225,11 @@ static int smb_lookup_validate(struct dentry * dentry)
* we believe in dentries for 5 seconds. (But each
* successful server lookup renews the timestamp.)
*/
valid = age < 5 * HZ || IS_ROOT(dentry);
valid = (age <= SMBFS_MAX_AGE) || IS_ROOT(dentry);
#ifdef SMBFS_DEBUG_VERBOSE
if (!valid)
printk("smb_lookup_validate: %s/%s not valid, age=%d\n",
dentry->d_parent->d_name.name, dentry->d_name.name, age)
printk("smb_lookup_validate: %s/%s not valid, age=%lu\n",
dentry->d_parent->d_name.name, dentry->d_name.name, age);
#endif
if (inode)
......@@ -259,10 +253,20 @@ dentry->d_parent->d_name.name, dentry->d_name.name);
/*
* This is the callback from dput() when d_count is going to 0.
* We use this to close files and unhash dentries with bad inodes.
* We use this to unhash dentries with bad inodes and close files.
*/
static void smb_delete_dentry(struct dentry * dentry)
static void
smb_delete_dentry(struct dentry * dentry)
{
if ((jiffies - dentry->d_time) > SMBFS_MAX_AGE)
{
#ifdef SMBFS_DEBUG_VERBOSE
printk("smb_delete_dentry: %s/%s expired, d_time=%lu, now=%lu\n",
dentry->d_parent->d_name.name, dentry->d_name.name, dentry->d_time, jiffies);
#endif
d_drop(dentry);
}
if (dentry->d_inode)
{
if (is_bad_inode(dentry->d_inode))
......@@ -285,9 +289,11 @@ dentry->d_parent->d_name.name, dentry->d_name.name);
* are all valid, so we want to update the dentry timestamps.
* N.B. Move this to dcache?
*/
void smb_renew_times(struct dentry * dentry)
void
smb_renew_times(struct dentry * dentry)
{
for (;;) {
for (;;)
{
dentry->d_time = jiffies;
if (dentry == dentry->d_parent)
break;
......@@ -361,6 +367,10 @@ smb_instantiate(struct dentry *dentry)
error = 0;
}
}
#ifdef SMBFS_DEBUG_VERBOSE
printk("smb_instantiate: file %s/%s, error=%d\n",
dentry->d_parent->d_name.name, dentry->d_name.name, error);
#endif
return error;
}
......@@ -370,6 +380,10 @@ smb_create(struct inode *dir, struct dentry *dentry, int mode)
{
int error;
#ifdef SMBFS_DEBUG_VERBOSE
printk("smb_create: creating %s/%s, mode=%d\n",
dentry->d_parent->d_name.name, dentry->d_name.name, mode);
#endif
error = -ENAMETOOLONG;
if (dentry->d_name.len > SMB_MAXNAMELEN)
goto out;
......
......@@ -6,14 +6,10 @@
*
*/
#define SMBFS_DCACHE_EXT 1
#include <linux/config.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/smb_fs.h>
#include <linux/smbno.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
......@@ -23,6 +19,9 @@
#include <linux/malloc.h>
#include <linux/init.h>
#include <linux/dcache.h>
#include <linux/smb_fs.h>
#include <linux/smbno.h>
#include <linux/smb_mount.h>
#include <asm/system.h>
#include <asm/uaccess.h>
......@@ -30,17 +29,11 @@
#define SMBFS_PARANOIA 1
/* #define SMBFS_DEBUG_VERBOSE 1 */
#ifndef SMBFS_DCACHE_EXT
#define shrink_dcache_sb(sb) shrink_dcache()
#endif
extern void smb_renew_times(struct dentry *);
extern int close_fp(struct file *filp);
static void smb_read_inode(struct inode *);
static void smb_put_inode(struct inode *);
static void smb_delete_inode(struct inode *);
static void smb_read_inode(struct inode *);
static void smb_put_super(struct super_block *);
static int smb_statfs(struct super_block *, struct statfs *, int);
static int smb_statfs(struct super_block *, struct statfs *, int);
static struct super_operations smb_sops =
{
......@@ -147,6 +140,11 @@ printk("smb_invalidate_inodes\n");
invalidate_inodes(SB_of(server));
}
/*
* This is called when we want to check whether the inode
* has changed on the server. If it has changed, we must
* invalidate our local caches.
*/
int
smb_revalidate_inode(struct inode *inode)
{
......@@ -167,25 +165,23 @@ jiffies, inode->u.smbfs_i.oldmtime);
}
/*
* Save the last modified time, then refresh the inode
* Save the last modified time, then refresh the inode.
* (Note: a size change should have a different mtime.)
*/
last_time = inode->i_mtime;
error = smb_refresh_inode(inode);
if (!error)
if (error || inode->i_mtime != last_time)
{
if (inode->i_mtime != last_time)
{
#ifdef SMBFS_DEBUG_VERBOSE
printk("smb_revalidate: %s/%s changed, old=%ld, new=%ld\n",
((struct dentry *)inode->u.smbfs_i.dentry)->d_parent->d_name.name,
((struct dentry *)inode->u.smbfs_i.dentry)->d_name.name,
(long) last_time, (long) inode->i_mtime);
#endif
if (!S_ISDIR(inode->i_mode))
invalidate_inode_pages(inode);
else
smb_invalid_dir_cache(inode);
}
if (!S_ISDIR(inode->i_mode))
invalidate_inode_pages(inode);
else
smb_invalid_dir_cache(inode);
}
out:
return error;
......@@ -253,10 +249,12 @@ inode->i_mode, fattr.f_mode);
/*
* No need to worry about unhashing the dentry: the
* lookup validation will see that the inode is bad.
* But we may need to invalidate the caches ...
* But we do want to invalidate the caches ...
*/
invalidate_inode_pages(inode);
smb_invalid_dir_cache(inode);
if (!S_ISDIR(inode->i_mode))
invalidate_inode_pages(inode);
else
smb_invalid_dir_cache(inode);
error = -EIO;
}
}
......@@ -328,6 +326,7 @@ smb_put_super(struct super_block *sb)
if (server->conn_pid)
kill_proc(server->conn_pid, SIGTERM, 0);
kfree(server->mnt);
if (server->packet)
smb_vfree(server->packet);
sb->s_dev = 0;
......@@ -340,7 +339,7 @@ smb_put_super(struct super_block *sb)
struct super_block *
smb_read_super(struct super_block *sb, void *raw_data, int silent)
{
struct smb_mount_data *data = (struct smb_mount_data *)raw_data;
struct smb_mount_data *mnt, *data = (struct smb_mount_data *) raw_data;
struct smb_fattr root;
kdev_t dev = sb->s_dev;
struct inode *root_inode;
......@@ -368,16 +367,25 @@ smb_read_super(struct super_block *sb, void *raw_data, int silent)
sb->u.smbfs_sb.conn_pid = 0;
sb->u.smbfs_sb.state = CONN_INVALID; /* no connection yet */
sb->u.smbfs_sb.generation = 0;
sb->u.smbfs_sb.packet_size = SMB_INITIAL_PACKET_SIZE;
sb->u.smbfs_sb.packet = smb_vmalloc(SMB_INITIAL_PACKET_SIZE);
sb->u.smbfs_sb.packet_size = smb_round_length(SMB_INITIAL_PACKET_SIZE);
sb->u.smbfs_sb.packet = smb_vmalloc(sb->u.smbfs_sb.packet_size);
if (!sb->u.smbfs_sb.packet)
goto out_no_mem;
sb->u.smbfs_sb.m = *data;
sb->u.smbfs_sb.m.file_mode = (sb->u.smbfs_sb.m.file_mode &
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG;
sb->u.smbfs_sb.m.dir_mode = (sb->u.smbfs_sb.m.dir_mode &
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFDIR;
mnt = kmalloc(sizeof(struct smb_mount_data), GFP_KERNEL);
if (!mnt)
goto out_no_mount;
*mnt = *data;
mnt->version = 0; /* dynamic flags */
#ifdef CONFIG_SMB_WIN95
mnt->version |= 1;
#endif
mnt->file_mode &= (S_IRWXU | S_IRWXG | S_IRWXO);
mnt->file_mode |= S_IFREG;
mnt->dir_mode &= (S_IRWXU | S_IRWXG | S_IRWXO);
mnt->dir_mode |= S_IFDIR;
sb->u.smbfs_sb.mnt = mnt;
/*
* Keep the super block locked while we get the root inode.
*/
......@@ -398,20 +406,20 @@ smb_read_super(struct super_block *sb, void *raw_data, int silent)
out_no_root:
printk(KERN_ERR "smb_read_super: get root inode failed\n");
iput(root_inode);
kfree(sb->u.smbfs_sb.mnt);
out_no_mount:
smb_vfree(sb->u.smbfs_sb.packet);
goto out_unlock;
out_no_mem:
printk("smb_read_super: could not alloc packet\n");
goto out_unlock;
out_unlock:
unlock_super(sb);
goto out_fail;
out_wrong_data:
printk(KERN_ERR "smb_read_super: wrong data argument."
" Recompile smbmount.\n");
printk("smb_read_super: need mount version %d\n", SMB_MOUNT_VERSION);
goto out_fail;
out_no_data:
printk("smb_read_super: missing data argument\n");
goto out_fail;
out_unlock:
unlock_super(sb);
out_fail:
sb->s_dev = 0;
MOD_DEC_USE_COUNT;
......@@ -439,6 +447,7 @@ smb_notify_change(struct inode *inode, struct iattr *attr)
{
struct smb_sb_info *server = SMB_SERVER(inode);
struct dentry *dentry = inode->u.smbfs_i.dentry;
unsigned int mask = (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO);
int error, refresh = 0;
error = -EIO;
......@@ -459,14 +468,13 @@ smb_notify_change(struct inode *inode, struct iattr *attr)
goto out;
error = -EPERM;
if (((attr->ia_valid & ATTR_UID) && (attr->ia_uid != server->m.uid)))
if ((attr->ia_valid & ATTR_UID) && (attr->ia_uid != server->mnt->uid))
goto out;
if (((attr->ia_valid & ATTR_GID) && (attr->ia_uid != server->m.gid)))
if ((attr->ia_valid & ATTR_GID) && (attr->ia_uid != server->mnt->gid))
goto out;
if (((attr->ia_valid & ATTR_MODE) &&
(attr->ia_mode & ~(S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO))))
if ((attr->ia_valid & ATTR_MODE) && (attr->ia_mode & ~mask))
goto out;
if ((attr->ia_valid & ATTR_SIZE) != 0)
......
......@@ -8,10 +8,11 @@
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/smb_fs.h>
#include <linux/ioctl.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/smb_fs.h>
#include <linux/smb_mount.h>
#include <asm/uaccess.h>
......@@ -19,33 +20,33 @@ int
smb_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
int result = -EINVAL;
switch (cmd)
{
case SMB_IOC_GETMOUNTUID:
return put_user(SMB_SERVER(inode)->m.mounted_uid,
result = put_user(SMB_SERVER(inode)->mnt->mounted_uid,
(uid_t *) arg);
break;
case SMB_IOC_NEWCONN:
{
struct smb_conn_opt opt;
int result;
if (arg == 0)
{
/* The process offers a new connection upon SIGUSR1 */
return smb_offerconn(SMB_SERVER(inode));
result = smb_offerconn(SMB_SERVER(inode));
}
if ((result = verify_area(VERIFY_READ, (uid_t *) arg,
sizeof(opt))) != 0)
else
{
return result;
result = -EFAULT;
if (!copy_from_user(&opt, (void *)arg, sizeof(opt)))
result = smb_newconn(SMB_SERVER(inode), &opt);
}
copy_from_user(&opt, (void *)arg, sizeof(opt));
return smb_newconn(SMB_SERVER(inode), &opt);
break;
}
default:
return -EINVAL;
}
return result;
}
This diff is collapsed.
This diff is collapsed.
......@@ -1415,8 +1415,9 @@ int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,
struct buffer_head *old_bh,*new_bh,*dotdot_bh;
struct msdos_dir_entry *old_de,*new_de,*dotdot_de;
loff_t old_offset,new_offset,old_longname_offset;
int old_slots,old_ino,new_ino,dotdot_ino,ino;
struct inode *old_inode, *new_inode, *dotdot_inode, *walk;
int old_slots,old_ino,new_ino,dotdot_ino;
struct inode *old_inode, *new_inode, *dotdot_inode;
struct dentry *walk;
int res, is_dir, i;
int locked = 0;
struct slot_info sinfo;
......@@ -1451,25 +1452,13 @@ int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,
res = -EINVAL;
goto rename_done;
}
if (!(walk = iget(new_dir->i_sb,new_dir->i_ino))) return -EIO;
walk = new_dentry;
/* prevent moving directory below itself */
while (walk->i_ino != MSDOS_ROOT_INO) {
ino = fat_parent_ino(walk,1);
iput(walk);
if (ino < 0) {
res = ino;
goto rename_done;
}
if (ino == old_ino) {
res = -EINVAL;
goto rename_done;
}
if (!(walk = iget(new_dir->i_sb,ino))) {
res = -EIO;
goto rename_done;
}
for (;;) {
if (walk == old_dentry) return -EINVAL;
if (walk == walk->d_parent) break;
walk = walk->d_parent;
}
iput(walk);
}
res = vfat_find(new_dir,&new_dentry->d_name,1,0,is_dir,&sinfo);
......@@ -1589,8 +1578,9 @@ int vfat_rename(struct inode *old_dir,struct dentry *old_dentry,
}
if (res > 0) res = 0;
d_instantiate(new_dentry,new_inode);
d_delete(old_dentry);
if (res == 0) {
d_move(old_dentry, new_dentry);
}
rename_done:
if (locked)
......
#ifndef _ASM_SOCKET_H
#define _ASM_SOCKET_H
#include <linux/types.h>
#include <asm/ioctl.h>
#include <asm/sockios.h>
/* For setsockoptions(2) */
......
......@@ -17,7 +17,8 @@
*/
struct qstr {
const unsigned char * name;
unsigned int len, hash;
unsigned int len;
unsigned int hash;
};
/* Name hashing routines. Initial hash value */
......@@ -38,6 +39,15 @@ static inline unsigned long end_name_hash(unsigned long hash)
return (unsigned int) hash;
}
/* Compute the hash for a name string. */
static inline unsigned int full_name_hash(const char * name, unsigned int len)
{
unsigned long hash = init_name_hash();
while (len--)
hash = partial_name_hash(*name++, hash);
return end_name_hash(hash);
}
struct dentry {
int d_count;
unsigned int d_flags;
......
......@@ -176,7 +176,7 @@ extern int nfs_lock(struct file *file, int cmd, struct file_lock *fl);
*/
extern int nfs_writepage(struct inode *, struct page *);
extern int nfs_check_error(struct inode *);
extern int nfs_flush_dirty_pages(struct inode *, off_t, off_t);
extern int nfs_flush_dirty_pages(struct inode *, pid_t, off_t, off_t);
extern int nfs_truncate_dirty_pages(struct inode *, unsigned long);
extern void nfs_invalidate_pages(struct inode *);
extern int nfs_updatepage(struct inode *, struct page *, const char *,
......
......@@ -41,7 +41,7 @@
#undef __FDMASK
#define __FDMASK(d) (1UL << ((d) % __NFDBITS))
typedef struct fd_set {
typedef struct {
unsigned long fds_bits [__FDSET_LONGS];
} __kernel_fd_set;
......
......@@ -65,20 +65,18 @@ smb_vfree(void *obj)
#endif /* DEBUG_SMB_MALLOC */
struct smb_sb_info;
/* linux/fs/smbfs/mmap.c */
int smb_mmap(struct file *, struct vm_area_struct *);
/* linux/fs/smbfs/file.c */
extern struct inode_operations smb_file_inode_operations;
/* linux/fs/smbfs/dir.c */
extern struct inode_operations smb_dir_inode_operations;
void smb_init_root(struct smb_sb_info *);
int smb_stat_root(struct smb_sb_info *);
void smb_renew_times(struct dentry *);
/* linux/fs/smbfs/ioctl.c */
int smb_ioctl (struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg);
int smb_ioctl (struct inode *, struct file *, unsigned int, unsigned long);
/* linux/fs/smbfs/inode.c */
struct super_block *smb_read_super(struct super_block *, void *, int);
......@@ -126,6 +124,7 @@ int smb_proc_trunc(struct smb_sb_info *, __u16, __u32);
void smb_init_root_dirent(struct smb_sb_info *server, struct smb_fattr *);
/* linux/fs/smbfs/sock.c */
int smb_round_length(int);
int smb_valid_socket(struct inode *);
void smb_close_socket(struct smb_sb_info *);
int smb_release(struct smb_sb_info *server);
......@@ -141,9 +140,6 @@ int smb_trans2_request(struct smb_sb_info *server, __u16 trans2_command,
int *lrdata, unsigned char **rdata,
int *lrparam, unsigned char **rparam);
/* linux/fs/smbfs/mmap.c */
int smb_mmap(struct file * file, struct vm_area_struct * vma);
/* fs/smbfs/cache.c */
/*
......@@ -206,7 +202,7 @@ struct cache_head * smb_get_dircache(struct dentry *);
void smb_init_dircache(struct cache_head *);
void smb_free_dircache(struct cache_head *);
int smb_refill_dircache(struct cache_head *, struct dentry *);
void smb_add_to_cache(struct cache_head *, struct dirent *, off_t);
void smb_add_to_cache(struct cache_head *, struct cache_dirent *, off_t);
int smb_find_in_cache(struct cache_head *, off_t, struct cache_dirent *);
void smb_invalid_dir_cache(struct inode *);
......
......@@ -13,7 +13,6 @@
#include <linux/types.h>
#include <linux/smb.h>
#include <linux/smb_mount.h>
/* Get the server for the specified dentry */
#define server_from_dentry(dentry) &dentry->d_sb->u.smbfs_sb
......@@ -24,7 +23,7 @@ struct smb_sb_info {
enum smb_conn_state state;
struct file * sock_file;
struct smb_mount_data m;
struct smb_mount_data *mnt;
/* Connections are counted. Each time a new socket arrives,
* generation is incremented.
......
......@@ -92,25 +92,21 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
struct mm_struct *mm = current->mm;
lock_kernel();
retval = mm->brk;
if (brk < mm->end_code)
goto out;
newbrk = PAGE_ALIGN(brk);
oldbrk = PAGE_ALIGN(mm->brk);
if (oldbrk == newbrk) {
retval = mm->brk = brk;
goto out;
}
if (oldbrk == newbrk)
goto set_brk;
/* Always allow shrinking brk. */
if (brk <= mm->brk) {
retval = mm->brk = brk;
do_munmap(newbrk, oldbrk-newbrk);
if (!do_munmap(newbrk, oldbrk-newbrk))
goto set_brk;
goto out;
}
/* Check against rlimit and stack.. */
retval = mm->brk;
rlim = current->rlim[RLIMIT_DATA].rlim_cur;
if (rlim >= RLIM_INFINITY)
rlim = ~0;
......@@ -126,12 +122,14 @@ asmlinkage unsigned long sys_brk(unsigned long brk)
goto out;
/* Ok, looks good - let it rip. */
if(do_mmap(NULL, oldbrk, newbrk-oldbrk,
if (do_mmap(NULL, oldbrk, newbrk-oldbrk,
PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_FIXED|MAP_PRIVATE, 0) == oldbrk)
mm->brk = brk;
retval = mm->brk;
MAP_FIXED|MAP_PRIVATE, 0) != oldbrk)
goto out;
set_brk:
mm->brk = brk;
out:
retval = mm->brk;
unlock_kernel();
return retval;
}
......@@ -163,7 +161,7 @@ unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
{
struct mm_struct * mm = current->mm;
struct vm_area_struct * vma;
int correct_wcount = 0;
int correct_wcount = 0, error;
if ((len = PAGE_ALIGN(len)) == 0)
return addr;
......@@ -262,26 +260,24 @@ unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
vma->vm_dentry = NULL;
vma->vm_pte = 0;
do_munmap(addr, len); /* Clear old maps */
/* Clear old maps */
error = -ENOMEM;
if (do_munmap(addr, len))
goto free_vma;
/* Check against address space limit. */
if ((mm->total_vm << PAGE_SHIFT) + len
> current->rlim[RLIMIT_AS].rlim_cur) {
kmem_cache_free(vm_area_cachep, vma);
return -ENOMEM;
}
> current->rlim[RLIMIT_AS].rlim_cur)
goto free_vma;
/* Private writable mapping? Check memory availability.. */
if ((vma->vm_flags & (VM_SHARED | VM_WRITE)) == VM_WRITE) {
if (!(flags & MAP_NORESERVE) &&
!vm_enough_memory(len >> PAGE_SHIFT)) {
kmem_cache_free(vm_area_cachep, vma);
return -ENOMEM;
}
}
if ((vma->vm_flags & (VM_SHARED | VM_WRITE)) == VM_WRITE &&
!(flags & MAP_NORESERVE) &&
!vm_enough_memory(len >> PAGE_SHIFT))
goto free_vma;
error = 0;
if (file) {
int error = 0;
if (vma->vm_flags & VM_DENYWRITE) {
if (file->f_dentry->d_inode->i_writecount > 0)
error = -ETXTBSY;
......@@ -298,23 +294,22 @@ unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
if (!error)
error = file->f_op->mmap(file, vma);
if (error) {
if (correct_wcount)
file->f_dentry->d_inode->i_writecount++;
kmem_cache_free(vm_area_cachep, vma);
return error;
}
}
/* Fix up the count if necessary, then check for an error */
if (correct_wcount)
file->f_dentry->d_inode->i_writecount++;
if (error)
goto free_vma;
/*
* merge_segments may merge our vma, so we can't refer to it
* after the call. Save the values we need now ...
*/
flags = vma->vm_flags;
addr = vma->vm_start; /* can addr have changed?? */
insert_vm_struct(mm, vma);
if (correct_wcount)
file->f_dentry->d_inode->i_writecount++;
merge_segments(mm, vma->vm_start, vma->vm_end);
addr = vma->vm_start;
/* merge_segments might have merged our vma, so we can't use it any more */
mm->total_vm += len >> PAGE_SHIFT;
if ((flags & VM_LOCKED) && !(flags & VM_IO)) {
unsigned long start = addr;
......@@ -328,6 +323,10 @@ unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
} while (len > 0);
}
return addr;
free_vma:
kmem_cache_free(vm_area_cachep, vma);
return error;
}
/* Get an address range which is currently unmapped.
......
......@@ -18,9 +18,6 @@
#include <linux/swapctl.h>
#include <linux/init.h>
#include <asm/dma.h>
#include <asm/system.h> /* for cli()/sti() */
#include <asm/uaccess.h> /* for cop_to/from_user */
#include <asm/bitops.h>
#include <asm/pgtable.h>
......@@ -60,31 +57,47 @@ int add_to_swap_cache(struct page *page, unsigned long entry)
return 0;
}
/*
* If swap_map[] reaches 127, the entries are treated as "permanent".
*/
void swap_duplicate(unsigned long entry)
{
struct swap_info_struct * p;
unsigned long offset, type;
if (!entry)
return;
offset = SWP_OFFSET(entry);
goto out;
type = SWP_TYPE(entry);
if (type & SHM_SWP_TYPE)
return;
if (type >= nr_swapfiles) {
printk("Trying to duplicate nonexistent swap-page\n");
return;
}
goto out;
if (type >= nr_swapfiles)
goto bad_file;
p = type + swap_info;
if (offset >= p->max) {
printk("swap_duplicate: weirdness\n");
return;
}
if (!p->swap_map[offset]) {
printk("swap_duplicate: trying to duplicate unused page\n");
return;
offset = SWP_OFFSET(entry);
if (offset >= p->max)
goto bad_offset;
if (!p->swap_map[offset])
goto bad_unused;
if (p->swap_map[offset] < 126)
p->swap_map[offset]++;
else {
static int overflow = 0;
if (overflow++ < 5)
printk("swap_duplicate: entry %08lx map count=%d\n",
entry, p->swap_map[offset]);
p->swap_map[offset] = 127;
}
p->swap_map[offset]++;
out:
return;
bad_file:
printk("swap_duplicate: Trying to duplicate nonexistent swap-page\n");
goto out;
bad_offset:
printk("swap_duplicate: offset exceeds max\n");
goto out;
bad_unused:
printk("swap_duplicate: unused page\n");
goto out;
}
......@@ -21,11 +21,7 @@
#include <linux/malloc.h>
#include <linux/blkdev.h> /* for blk_size */
#include <linux/vmalloc.h>
#include <linux/dcache.h>
#include <asm/dma.h>
#include <asm/system.h> /* for cli()/sti() */
#include <asm/uaccess.h> /* for copy_to/from_user */
#include <asm/bitops.h>
#include <asm/pgtable.h>
......@@ -122,52 +118,60 @@ unsigned long get_swap_page(void)
}
}
/*
* If the swap count overflows (swap_map[] == 127), the entry is considered
* "permanent" and can't be reclaimed until the swap device is closed.
*/
void swap_free(unsigned long entry)
{
struct swap_info_struct * p;
unsigned long offset, type;
if (!entry)
return;
goto out;
type = SWP_TYPE(entry);
if (type & SHM_SWP_TYPE)
return;
if (type >= nr_swapfiles) {
printk("Trying to free nonexistent swap-page\n");
return;
}
goto out;
if (type >= nr_swapfiles)
goto bad_nofile;
p = & swap_info[type];
if (!(p->flags & SWP_USED))
goto bad_device;
if (p->prio > swap_info[swap_list.next].prio)
swap_list.next = swap_list.head;
offset = SWP_OFFSET(entry);
if (offset >= p->max) {
printk("swap_free: weirdness\n");
return;
}
if (!(p->flags & SWP_USED)) {
printk("Trying to free swap from unused swap-device\n");
return;
}
if (offset >= p->max)
goto bad_offset;
if (offset < p->lowest_bit)
p->lowest_bit = offset;
if (offset > p->highest_bit)
p->highest_bit = offset;
if (!p->swap_map[offset])
printk("swap_free: swap-space map bad (entry %08lx)\n",entry);
else
goto bad_free;
if (p->swap_map[offset] < 127) {
if (!--p->swap_map[offset])
nr_swap_pages++;
if (p->prio > swap_info[swap_list.next].prio) {
swap_list.next = swap_list.head;
}
out:
return;
bad_nofile:
printk("swap_free: Trying to free nonexistent swap-page\n");
goto out;
bad_device:
printk("swap_free: Trying to free swap from unused swap-device\n");
goto out;
bad_offset:
printk("swap_free: offset exceeds max\n");
goto out;
bad_free:
printk("swap_free: swap-space map bad (entry %08lx)\n",entry);
goto out;
}
/*
* Trying to stop swapping from a file is fraught with races, so
* we repeat quite a bit here when we have to pause. swapoff()
* isn't exactly timing-critical, so who cares (but this is /really/
* inefficient, ugh).
*
* We return 1 after having slept, which makes the process start over
* from the beginning for this process..
* The swap entry has been read in advance, and we return 1 to indicate
* that the page has been used or is no longer needed.
*/
static inline int unuse_pte(struct vm_area_struct * vma, unsigned long address,
pte_t *dir, unsigned long entry, unsigned long page)
......@@ -198,9 +202,8 @@ static inline int unuse_pte(struct vm_area_struct * vma, unsigned long address,
if (pte_val(pte) != entry)
return 0;
set_pte(dir, pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot))));
flush_tlb_page(vma, address);
++vma->vm_mm->rss;
swap_free(pte_val(pte));
swap_free(entry);
return 1;
}
......@@ -296,18 +299,6 @@ static int unuse_process(struct mm_struct * mm, unsigned long entry,
return 0;
}
static unsigned long find_swap_entry(int type)
{
struct swap_info_struct * p = &swap_info[type];
int i;
for (i = 1 ; i < p->max ; i++) {
if (p->swap_map[i] > 0 && p->swap_map[i] != 0x80)
return SWP_ENTRY(type, i);
}
return 0;
}
/*
* We completely avoid races by reading each swap page in advance,
* and then search for the process using it. All the necessary
......@@ -315,14 +306,13 @@ static unsigned long find_swap_entry(int type)
*/
static int try_to_unuse(unsigned int type)
{
unsigned long page = 0;
struct swap_info_struct * si = &swap_info[type];
struct task_struct *p;
unsigned long page = 0;
unsigned long entry;
int i;
/*
* Find all swap entries in use ...
*/
while ((entry = find_swap_entry(type)) != 0) {
while (1) {
if (!page) {
page = __get_free_page(GFP_KERNEL);
if (!page)
......@@ -330,8 +320,16 @@ static int try_to_unuse(unsigned int type)
}
/*
* Read in the page, and then free the swap page.
*/
* Find a swap page in use and read it in.
*/
for (i = 1 , entry = 0; i < si->max ; i++) {
if (si->swap_map[i] > 0 && si->swap_map[i] != 0x80) {
entry = SWP_ENTRY(type, i);
break;
}
}
if (!entry)
break;
read_swap_page(entry, (char *) page);
read_lock(&tasklist_lock);
......@@ -344,9 +342,19 @@ static int try_to_unuse(unsigned int type)
unlock:
read_unlock(&tasklist_lock);
if (page) {
printk("try_to_unuse: didn't find entry %8lx\n",
entry);
swap_free(entry);
/*
* If we couldn't find an entry, there are several
* possible reasons: someone else freed it first,
* we freed the last reference to an overflowed entry,
* or the system has lost track of the use counts.
*/
if (si->swap_map[i] != 0) {
if (si->swap_map[i] != 127)
printk("try_to_unuse: entry %08lx "
"not in use\n", entry);
si->swap_map[i] = 0;
nr_swap_pages++;
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment