Commit de9c00e8 authored by Linus Torvalds's avatar Linus Torvalds

Date: 1 Mar 1998 05:08:07 GMT

Subject: Re: INN doesn't work on pre-2.1.89-4 (mmap problem ?)
From: Linus Torvalds <torvalds@transmeta.com>

I fixed _one_ silly bug wrt writeback to shared files in pre-5
parent 17e3d4ce
...@@ -807,6 +807,7 @@ do_load_elf_library(int fd) ...@@ -807,6 +807,7 @@ do_load_elf_library(int fd)
unsigned long elf_bss = 0, bss, len, k; unsigned long elf_bss = 0, bss, len, k;
int retval, error, i, j; int retval, error, i, j;
struct elfhdr elf_ex; struct elfhdr elf_ex;
loff_t offset = 0;
error = -EACCES; error = -EACCES;
file = fget(fd); file = fget(fd);
...@@ -817,17 +818,10 @@ do_load_elf_library(int fd) ...@@ -817,17 +818,10 @@ do_load_elf_library(int fd)
/* seek to the beginning of the file */ /* seek to the beginning of the file */
error = -ENOEXEC; error = -ENOEXEC;
if (file->f_op->llseek) {
retval = file->f_op->llseek(file, 0, 0);
if (retval != 0)
goto out_putf;
} else
file->f_pos = 0;
/* N.B. save current DS?? */ /* N.B. save current DS?? */
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
retval = file->f_op->read(file, (char *) &elf_ex, retval = file->f_op->read(file, (char *) &elf_ex, sizeof(elf_ex), &offset);
sizeof(elf_ex), &file->f_pos);
set_fs(USER_DS); set_fs(USER_DS);
if (retval != sizeof(elf_ex)) if (retval != sizeof(elf_ex))
goto out_putf; goto out_putf;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/coda_cache.h> #include <linux/coda_cache.h>
/* file operations */ /* file operations */
static int coda_readpage(struct dentry * dentry, struct page * page); static int coda_readpage(struct file *file, struct page * page);
static ssize_t coda_file_read(struct file *f, char *buf, size_t count, loff_t *off); static ssize_t coda_file_read(struct file *f, char *buf, size_t count, loff_t *off);
static ssize_t coda_file_write(struct file *f, const char *buf, size_t count, loff_t *off); static ssize_t coda_file_write(struct file *f, const char *buf, size_t count, loff_t *off);
static int coda_file_mmap(struct file * file, struct vm_area_struct * vma); static int coda_file_mmap(struct file * file, struct vm_area_struct * vma);
...@@ -74,8 +74,9 @@ struct file_operations coda_file_operations = { ...@@ -74,8 +74,9 @@ struct file_operations coda_file_operations = {
}; };
/* File file operations */ /* File file operations */
static int coda_readpage(struct dentry *de, struct page * page) static int coda_readpage(struct file * file, struct page * page)
{ {
struct dentry *de = file->f_dentry;
struct inode *inode = de->d_inode; struct inode *inode = de->d_inode;
struct dentry cont_dentry; struct dentry cont_dentry;
struct inode *cont_inode; struct inode *cont_inode;
......
...@@ -938,7 +938,7 @@ int quota_off(kdev_t dev, short type) ...@@ -938,7 +938,7 @@ int quota_off(kdev_t dev, short type)
vfsmnt->mnt_sb->dq_op = (struct dquot_operations *)NULL; vfsmnt->mnt_sb->dq_op = (struct dquot_operations *)NULL;
reset_dquot_ptrs(dev, cnt); reset_dquot_ptrs(dev, cnt);
invalidate_dquots(dev, cnt); invalidate_dquots(dev, cnt);
close_fp(vfsmnt->mnt_quotas[cnt]); fput(vfsmnt->mnt_quotas[cnt]);
vfsmnt->mnt_quotas[cnt] = (struct file *)NULL; vfsmnt->mnt_quotas[cnt] = (struct file *)NULL;
vfsmnt->mnt_iexp[cnt] = vfsmnt->mnt_bexp[cnt] = (time_t)NULL; vfsmnt->mnt_iexp[cnt] = vfsmnt->mnt_bexp[cnt] = (time_t)NULL;
} }
......
...@@ -119,8 +119,9 @@ int fat_mmap(struct file * file, struct vm_area_struct * vma) ...@@ -119,8 +119,9 @@ int fat_mmap(struct file * file, struct vm_area_struct * vma)
} }
int fat_readpage(struct dentry * dentry, struct page * page) int fat_readpage(struct file *file, struct page * page)
{ {
struct dentry * dentry = file->f_dentry;
struct inode * inode = dentry->d_inode; struct inode * inode = dentry->d_inode;
if (MSDOS_SB(inode->i_sb)->cvf_format && if (MSDOS_SB(inode->i_sb)->cvf_format &&
MSDOS_SB(inode->i_sb)->cvf_format->cvf_readpage) MSDOS_SB(inode->i_sb)->cvf_format->cvf_readpage)
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include <linux/ncp_fs.h> #include <linux/ncp_fs.h>
#include "ncplib_kernel.h" #include "ncplib_kernel.h"
extern int close_fp(struct file *filp);
static void ncp_read_inode(struct inode *); static void ncp_read_inode(struct inode *);
static void ncp_put_inode(struct inode *); static void ncp_put_inode(struct inode *);
static void ncp_delete_inode(struct inode *); static void ncp_delete_inode(struct inode *);
...@@ -353,7 +351,7 @@ static void ncp_put_super(struct super_block *sb) ...@@ -353,7 +351,7 @@ static void ncp_put_super(struct super_block *sb)
ncp_disconnect(server); ncp_disconnect(server);
ncp_unlock_server(server); ncp_unlock_server(server);
close_fp(server->ncp_filp); fput(server->ncp_filp);
kill_proc(server->m.wdog_pid, SIGTERM, 1); kill_proc(server->m.wdog_pid, SIGTERM, 1);
ncp_kfree_s(server->packet, server->packet_size); ncp_kfree_s(server->packet, server->packet_size);
......
...@@ -610,30 +610,42 @@ static inline char * task_name(struct task_struct *p, char * buf) ...@@ -610,30 +610,42 @@ static inline char * task_name(struct task_struct *p, char * buf)
return buf+1; return buf+1;
} }
static inline char * task_state(struct task_struct *p, char *buffer) static const char *task_state_array[] = {
". Huh?",
"R (running)",
"S (sleeping)",
"D (disk sleep)",
"Z (zombie)",
"T (stopped)",
"W (paging)"
};
static inline const char * get_task_state(struct task_struct *tsk)
{ {
#define NR_STATES (sizeof(states)/sizeof(const char *)) unsigned int state = tsk->state & (TASK_RUNNING |
unsigned int n = p->state; TASK_INTERRUPTIBLE |
static const char * states[] = { TASK_UNINTERRUPTIBLE |
"R (running)", TASK_ZOMBIE |
"S (sleeping)", TASK_STOPPED |
"D (disk sleep)", TASK_SWAPPING);
"Z (zombie)", const char **p = &task_state_array[0];
"T (stopped)",
"W (paging)", while (state) {
". Huh?" p++;
}; state >>= 1;
}
if (n >= NR_STATES) return *p;
n = NR_STATES-1; }
static inline char * task_state(struct task_struct *p, char *buffer)
{
buffer += sprintf(buffer, buffer += sprintf(buffer,
"State:\t%s\n" "State:\t%s\n"
"Pid:\t%d\n" "Pid:\t%d\n"
"PPid:\t%d\n" "PPid:\t%d\n"
"Uid:\t%d\t%d\t%d\t%d\n" "Uid:\t%d\t%d\t%d\t%d\n"
"Gid:\t%d\t%d\t%d\t%d\n", "Gid:\t%d\t%d\t%d\t%d\n",
states[n], get_task_state(p),
p->pid, p->p_pptr->pid, p->pid, p->p_pptr->pid,
p->uid, p->euid, p->suid, p->fsuid, p->uid, p->euid, p->suid, p->fsuid,
p->gid, p->egid, p->sgid, p->fsgid); p->gid, p->egid, p->sgid, p->fsgid);
...@@ -769,10 +781,7 @@ static int get_stat(int pid, char * buffer) ...@@ -769,10 +781,7 @@ static int get_stat(int pid, char * buffer)
if (!tsk) if (!tsk)
return 0; return 0;
if (tsk->state < 0 || tsk->state > 5) state = *get_task_state(tsk);
state = '.';
else
state = "RSDZTW"[tsk->state];
vsize = eip = esp = 0; vsize = eip = esp = 0;
if (tsk->mm && tsk->mm != &init_mm) { if (tsk->mm && tsk->mm != &init_mm) {
struct vm_area_struct *vma = tsk->mm->mmap; struct vm_area_struct *vma = tsk->mm->mmap;
......
...@@ -390,8 +390,9 @@ romfs_lookup(struct inode *dir, struct dentry *dentry) ...@@ -390,8 +390,9 @@ romfs_lookup(struct inode *dir, struct dentry *dentry)
*/ */
static int static int
romfs_readpage(struct dentry * dentry, struct page * page) romfs_readpage(struct file * file, struct page * page)
{ {
struct dentry *dentry = file->f_dentry;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
unsigned long buf; unsigned long buf;
unsigned long offset, avail, readlen; unsigned long offset, avail, readlen;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/locks.h> #include <linux/locks.h>
#include <linux/malloc.h> #include <linux/malloc.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/file.h>
#include <linux/dcache.h> #include <linux/dcache.h>
#include <linux/smb_fs.h> #include <linux/smb_fs.h>
...@@ -326,7 +327,7 @@ smb_put_super(struct super_block *sb) ...@@ -326,7 +327,7 @@ smb_put_super(struct super_block *sb)
if (server->sock_file) { if (server->sock_file) {
smb_proc_disconnect(server); smb_proc_disconnect(server);
smb_dont_catch_keepalive(server); smb_dont_catch_keepalive(server);
close_fp(server->sock_file); fput(server->sock_file);
} }
if (server->conn_pid) if (server->conn_pid)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/socket.h> #include <linux/socket.h>
#include <linux/fcntl.h> #include <linux/fcntl.h>
#include <linux/file.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/net.h> #include <linux/net.h>
#include <linux/mm.h> #include <linux/mm.h>
...@@ -259,7 +260,7 @@ if (server_sock(server)->sk->data_ready == smb_data_callback) ...@@ -259,7 +260,7 @@ if (server_sock(server)->sk->data_ready == smb_data_callback)
printk("smb_close_socket: still catching keepalives!\n"); printk("smb_close_socket: still catching keepalives!\n");
#endif #endif
server->sock_file = NULL; server->sock_file = NULL;
close_fp(file); fput(file);
} }
} }
......
...@@ -422,6 +422,8 @@ extern int init_private_file(struct file *, struct dentry *, int); ...@@ -422,6 +422,8 @@ extern int init_private_file(struct file *, struct dentry *, int);
* The POSIX file lock owner is determined by * The POSIX file lock owner is determined by
* the "struct files_struct" in the thread group * the "struct files_struct" in the thread group
* (or NULL for no owner - BSD locks). * (or NULL for no owner - BSD locks).
*
* Lockd stuffs a "host" pointer into this.
*/ */
typedef struct files_struct *fl_owner_t; typedef struct files_struct *fl_owner_t;
......
...@@ -255,7 +255,7 @@ extern void fat_truncate(struct inode *inode); ...@@ -255,7 +255,7 @@ extern void fat_truncate(struct inode *inode);
/* mmap.c */ /* mmap.c */
extern int fat_mmap(struct file *, struct vm_area_struct *); extern int fat_mmap(struct file *, struct vm_area_struct *);
extern int fat_readpage(struct dentry *, struct page *); extern int fat_readpage(struct file *, struct page *);
/* vfat.c */ /* vfat.c */
......
...@@ -294,12 +294,12 @@ struct ufs_inode { ...@@ -294,12 +294,12 @@ struct ufs_inode {
} ui_addr; } ui_addr;
__u8 ui_symlink[4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */ __u8 ui_symlink[4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */
} ui_u2; } ui_u2;
__u32 ui_flags; /* 0x64 unused -- "status flags (chflags)" ??? */ __u32 ui_flags; /* 0x64 immutable, append-only... */
__u32 ui_blocks; /* 0x68 blocks in use */ __u32 ui_blocks; /* 0x68 blocks in use */
__u32 ui_gen; /* 0x6c generation number XXX - what is this? */ __u32 ui_gen; /* 0x6c like ext2 i_version, for NFS support */
union { union {
struct { struct {
__u32 ui_shadow;/* 0x70 shadow inode XXX - what is this?*/ __u32 ui_shadow;/* 0x70 shadow inode with security data */
__u32 ui_uid; /* 0x74 long EFT version of uid */ __u32 ui_uid; /* 0x74 long EFT version of uid */
__u32 ui_gid; /* 0x78 long EFT version of gid */ __u32 ui_gid; /* 0x78 long EFT version of gid */
__u32 ui_oeftflag;/* 0x7c reserved */ __u32 ui_oeftflag;/* 0x7c reserved */
...@@ -318,6 +318,22 @@ struct ufs_inode { ...@@ -318,6 +318,22 @@ struct ufs_inode {
} ui_hurd; } ui_hurd;
} ui_u3; } ui_u3;
}; };
/* FreeBSD has these in sys/stat.h */
/* ui_flags that can be set by a file owner */
#define UFS_UF_SETTABLE 0x0000ffff
#define UFS_UF_NODUMP 0x00000001 /* do not dump */
#define UFS_UF_IMMUTABLE 0x00000002 /* immutable (can't "change") */
#define UFS_UF_APPEND 0x00000004 /* append-only */
#define UFS_UF_OPAQUE 0x00000008 /* directory is opaque (unionfs) */
#define UFS_UF_NOUNLINK 0x00000010 /* can't be removed or renamed */
/* ui_flags that only root can set */
#define UFS_SF_SETTABLE 0xffff0000
#define UFS_SF_ARCHIVED 0x00010000 /* archived */
#define UFS_SF_IMMUTABLE 0x00020000 /* immutable (can't "change") */
#define UFS_SF_APPEND 0x00040000 /* append-only */
#define UFS_SF_NOUNLINK 0x00100000 /* can't be removed or renamed */
#ifdef __KERNEL__ #ifdef __KERNEL__
/* /*
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/major.h> #include <linux/major.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/file.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -52,8 +53,6 @@ ...@@ -52,8 +53,6 @@
/* /*
* External references and all of the globals. * External references and all of the globals.
*/ */
extern int close_fp(struct file *);
void acct_timeout(unsigned long); void acct_timeout(unsigned long);
static volatile int acct_active = 0; static volatile int acct_active = 0;
...@@ -129,7 +128,7 @@ asmlinkage int sys_acct(const char *name) ...@@ -129,7 +128,7 @@ asmlinkage int sys_acct(const char *name)
del_timer(&acct_timer); del_timer(&acct_timer);
acct_active = 0; acct_active = 0;
acct_needcheck = 0; acct_needcheck = 0;
close_fp(acct_file); fput(acct_file);
} }
error = 0; error = 0;
goto out; goto out;
......
...@@ -154,7 +154,6 @@ EXPORT_SYMBOL(__namei); ...@@ -154,7 +154,6 @@ EXPORT_SYMBOL(__namei);
EXPORT_SYMBOL(lookup_dentry); EXPORT_SYMBOL(lookup_dentry);
EXPORT_SYMBOL(open_namei); EXPORT_SYMBOL(open_namei);
EXPORT_SYMBOL(sys_close); EXPORT_SYMBOL(sys_close);
EXPORT_SYMBOL(close_fp);
EXPORT_SYMBOL(d_alloc_root); EXPORT_SYMBOL(d_alloc_root);
EXPORT_SYMBOL(d_delete); EXPORT_SYMBOL(d_delete);
EXPORT_SYMBOL(d_validate); EXPORT_SYMBOL(d_validate);
......
...@@ -910,6 +910,7 @@ static inline int do_write_page(struct inode * inode, struct file * file, ...@@ -910,6 +910,7 @@ static inline int do_write_page(struct inode * inode, struct file * file,
{ {
int retval; int retval;
unsigned long size; unsigned long size;
loff_t loff = offset;
mm_segment_t old_fs; mm_segment_t old_fs;
size = offset + PAGE_SIZE; size = offset + PAGE_SIZE;
...@@ -925,8 +926,7 @@ static inline int do_write_page(struct inode * inode, struct file * file, ...@@ -925,8 +926,7 @@ static inline int do_write_page(struct inode * inode, struct file * file,
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
retval = -EIO; retval = -EIO;
if (size == file->f_op->write(file, (const char *) page, if (size == file->f_op->write(file, (const char *) page, size, &loff))
size, &file->f_pos))
retval = 0; retval = 0;
set_fs(old_fs); set_fs(old_fs);
return retval; return retval;
......
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