Commit b7c2deb6 authored by Linus Torvalds's avatar Linus Torvalds

Import 1.1.11

parent e695b6a4
...@@ -186,6 +186,14 @@ N: Ralf Flaxa ...@@ -186,6 +186,14 @@ N: Ralf Flaxa
E: rfflaxa@immd4.informatik.uni-erlangen.de E: rfflaxa@immd4.informatik.uni-erlangen.de
D: The Linux Support Team Erlangen D: The Linux Support Team Erlangen
N: Lawrence Foard
E: entropy@world.std.com
D: Floppy track reading, fs code
S: Suite #108
S: 217 Park Ave.
S: Worcester Ma 01609
S: USA
N: Nigel Gamble N: Nigel Gamble
E: nigel%gamble.uucp@gate.net E: nigel%gamble.uucp@gate.net
D: Interrupt-driven printer driver D: Interrupt-driven printer driver
......
VERSION = 1 VERSION = 1
PATCHLEVEL = 1 PATCHLEVEL = 1
SUBLEVEL = 10 SUBLEVEL = 11
all: Version zImage all: Version zImage
......
...@@ -52,8 +52,9 @@ static void extended_partition(struct gendisk *hd, int dev) ...@@ -52,8 +52,9 @@ static void extended_partition(struct gendisk *hd, int dev)
* This block is from a device that we're about to stomp on. * This block is from a device that we're about to stomp on.
* So make sure nobody thinks this block is usable. * So make sure nobody thinks this block is usable.
*/ */
bh->b_dirt=0; bh->b_dirt = 0;
bh->b_uptodate=0; bh->b_uptodate = 0;
bh->b_req = 0;
if (*(unsigned short *) (bh->b_data+510) == 0xAA55) { if (*(unsigned short *) (bh->b_data+510) == 0xAA55) {
p = (struct partition *) (0x1BE + bh->b_data); p = (struct partition *) (0x1BE + bh->b_data);
/* /*
...@@ -193,7 +194,7 @@ static void setup_dev(struct gendisk *dev) ...@@ -193,7 +194,7 @@ static void setup_dev(struct gendisk *dev)
blk_size[dev->major] = dev->sizes; blk_size[dev->major] = dev->sizes;
} }
void device_setup(void * BIOS) void device_setup(void)
{ {
struct gendisk *p; struct gendisk *p;
int nr=0; int nr=0;
......
...@@ -109,7 +109,7 @@ static int mmap_mem(struct inode * inode, struct file * file, ...@@ -109,7 +109,7 @@ static int mmap_mem(struct inode * inode, struct file * file,
mpnt->vm_offset = off; mpnt->vm_offset = off;
mpnt->vm_ops = NULL; mpnt->vm_ops = NULL;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
merge_segments(current->mmap, NULL, NULL); merge_segments(current->mm->mmap, NULL, NULL);
return 0; return 0;
} }
...@@ -202,7 +202,7 @@ static int mmap_zero(struct inode * inode, struct file * file, ...@@ -202,7 +202,7 @@ static int mmap_zero(struct inode * inode, struct file * file,
mpnt->vm_offset = off; mpnt->vm_offset = off;
mpnt->vm_ops = NULL; mpnt->vm_ops = NULL;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
merge_segments(current->mmap, ignoff_mergep, inode); merge_segments(current->mm->mmap, ignoff_mergep, inode);
return 0; return 0;
} }
......
...@@ -1650,7 +1650,7 @@ void do_SAK( struct tty_struct *tty) ...@@ -1650,7 +1650,7 @@ void do_SAK( struct tty_struct *tty)
send_sig(SIGKILL, *p, 1); send_sig(SIGKILL, *p, 1);
else { else {
for (i=0; i < NR_OPEN; i++) { for (i=0; i < NR_OPEN; i++) {
filp = (*p)->filp[i]; filp = (*p)->files->fd[i];
if (filp && (filp->f_op == &tty_fops) && if (filp && (filp->f_op == &tty_fops) &&
(MINOR(filp->f_rdev) == line)) { (MINOR(filp->f_rdev) == line)) {
send_sig(SIGKILL, *p, 1); send_sig(SIGKILL, *p, 1);
......
...@@ -596,7 +596,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host * shpnt) ...@@ -596,7 +596,7 @@ static void setup_mailboxes(int bse, struct Scsi_Host * shpnt)
struct mailbox * mb; struct mailbox * mb;
struct ccb *ccb; struct ccb *ccb;
unchar cmd[5] = {CMD_MBINIT, AHA1542_MAILBOXES}; unchar cmd[5] = {CMD_MBINIT, AHA1542_MAILBOXES, 0, 0, 0};
mb = HOSTDATA(shpnt)->mb; mb = HOSTDATA(shpnt)->mb;
ccb = HOSTDATA(shpnt)->ccb; ccb = HOSTDATA(shpnt)->ccb;
......
...@@ -160,10 +160,14 @@ sbintr (int unit) ...@@ -160,10 +160,14 @@ sbintr (int unit)
irq_ok = 1; irq_ok = 1;
break; break;
#ifndef EXCLUDE_MIDI
case IMODE_MIDI: case IMODE_MIDI:
sb_midi_interrupt (unit); sb_midi_interrupt (unit);
break; break;
#endif
default: default:
printk ("SoundBlaster: Unexpected interrupt\n"); printk ("SoundBlaster: Unexpected interrupt\n");
} }
......
...@@ -384,7 +384,7 @@ load_object (struct linux_binprm * bprm, struct pt_regs *regs, int lib_ok) ...@@ -384,7 +384,7 @@ load_object (struct linux_binprm * bprm, struct pt_regs *regs, int lib_ok)
status = fd; status = fd;
} }
else else
fp = current->filp[fd]; fp = current->files->fd[fd];
} }
else else
fd = -1; /* Invalidate the open file descriptor */ fd = -1; /* Invalidate the open file descriptor */
...@@ -441,8 +441,8 @@ load_object (struct linux_binprm * bprm, struct pt_regs *regs, int lib_ok) ...@@ -441,8 +441,8 @@ load_object (struct linux_binprm * bprm, struct pt_regs *regs, int lib_ok)
/* /*
* Define the initial locations for the various items in the new process * Define the initial locations for the various items in the new process
*/ */
current->mmap = NULL; current->mm->mmap = NULL;
current->rss = 0; current->mm->rss = 0;
/* /*
* Construct the parameter and environment string table entries. * Construct the parameter and environment string table entries.
*/ */
...@@ -455,20 +455,20 @@ load_object (struct linux_binprm * bprm, struct pt_regs *regs, int lib_ok) ...@@ -455,20 +455,20 @@ load_object (struct linux_binprm * bprm, struct pt_regs *regs, int lib_ok)
/* /*
* Do the end processing once the stack has been constructed * Do the end processing once the stack has been constructed
*/ */
current->start_code = text_vaddr & PAGE_MASK; current->mm->start_code = text_vaddr & PAGE_MASK;
current->end_code = text_vaddr + text_size; current->mm->end_code = text_vaddr + text_size;
current->end_data = data_vaddr + data_size; current->mm->end_data = data_vaddr + data_size;
current->start_brk = current->mm->start_brk =
current->brk = bss_vaddr + bss_size; current->mm->brk = bss_vaddr + bss_size;
current->suid = current->suid =
current->euid = bprm->e_uid; current->euid = bprm->e_uid;
current->sgid = current->sgid =
current->egid = bprm->e_gid; current->egid = bprm->e_gid;
current->executable = bprm->inode; /* Store inode for file */ current->executable = bprm->inode; /* Store inode for file */
++bprm->inode->i_count; /* Count the open inode */ ++bprm->inode->i_count; /* Count the open inode */
regs->eip = start_addr; /* Current EIP register */ regs->eip = start_addr; /* Current EIP register */
regs->esp = regs->esp =
current->start_stack = bprm->p; current->mm->start_stack = bprm->p;
} }
/* /*
* Map the text pages * Map the text pages
...@@ -756,7 +756,7 @@ load_coff_library (int fd) ...@@ -756,7 +756,7 @@ load_coff_library (int fd)
memset (bprm, '\0', sizeof (struct linux_binprm)); memset (bprm, '\0', sizeof (struct linux_binprm));
file = current->filp[fd]; file = current->files->fd[fd];
bprm->inode = file->f_inode; /* The only item _really_ needed */ bprm->inode = file->f_inode; /* The only item _really_ needed */
bprm->filename = ""; /* Make it a legal string */ bprm->filename = ""; /* Make it a legal string */
/* /*
......
...@@ -63,7 +63,7 @@ unsigned long * create_elf_tables(char * p,int argc,int envc,struct elfhdr * exe ...@@ -63,7 +63,7 @@ unsigned long * create_elf_tables(char * p,int argc,int envc,struct elfhdr * exe
mpnt->vm_offset = 0; mpnt->vm_offset = 0;
mpnt->vm_ops = NULL; mpnt->vm_ops = NULL;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
current->stk_vma = mpnt; current->mm->stk_vma = mpnt;
} }
sp = (unsigned long *) (0xfffffffc & (unsigned long) p); sp = (unsigned long *) (0xfffffffc & (unsigned long) p);
if(exec) sp -= DLINFO_ITEMS*2; if(exec) sp -= DLINFO_ITEMS*2;
...@@ -94,19 +94,19 @@ unsigned long * create_elf_tables(char * p,int argc,int envc,struct elfhdr * exe ...@@ -94,19 +94,19 @@ unsigned long * create_elf_tables(char * p,int argc,int envc,struct elfhdr * exe
}; };
put_fs_long((unsigned long)argc,--sp); put_fs_long((unsigned long)argc,--sp);
current->arg_start = (unsigned long) p; current->mm->arg_start = (unsigned long) p;
while (argc-->0) { while (argc-->0) {
put_fs_long((unsigned long) p,argv++); put_fs_long((unsigned long) p,argv++);
while (get_fs_byte(p++)) /* nothing */ ; while (get_fs_byte(p++)) /* nothing */ ;
} }
put_fs_long(0,argv); put_fs_long(0,argv);
current->arg_end = current->env_start = (unsigned long) p; current->mm->arg_end = current->mm->env_start = (unsigned long) p;
while (envc-->0) { while (envc-->0) {
put_fs_long((unsigned long) p,envp++); put_fs_long((unsigned long) p,envp++);
while (get_fs_byte(p++)) /* nothing */ ; while (get_fs_byte(p++)) /* nothing */ ;
} }
put_fs_long(0,envp); put_fs_long(0,envp);
current->env_end = (unsigned long) p; current->mm->env_end = (unsigned long) p;
return sp; return sp;
} }
...@@ -161,7 +161,7 @@ static unsigned int load_elf_interp(struct elfhdr * interp_elf_ex, ...@@ -161,7 +161,7 @@ static unsigned int load_elf_interp(struct elfhdr * interp_elf_ex,
elf_exec_fileno = open_inode(interpreter_inode, O_RDONLY); elf_exec_fileno = open_inode(interpreter_inode, O_RDONLY);
if (elf_exec_fileno < 0) return 0xffffffff; if (elf_exec_fileno < 0) return 0xffffffff;
file = current->filp[elf_exec_fileno]; file = current->files->fd[elf_exec_fileno];
eppnt = elf_phdata; eppnt = elf_phdata;
for(i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) for(i=0; i<interp_elf_ex->e_phnum; i++, eppnt++)
...@@ -210,9 +210,9 @@ static unsigned int load_aout_interp(struct exec * interp_ex, ...@@ -210,9 +210,9 @@ static unsigned int load_aout_interp(struct exec * interp_ex,
int retval; int retval;
unsigned int elf_entry; unsigned int elf_entry;
current->brk = interp_ex->a_bss + current->mm->brk = interp_ex->a_bss +
(current->end_data = interp_ex->a_data + (current->mm->end_data = interp_ex->a_data +
(current->end_code = interp_ex->a_text)); (current->mm->end_code = interp_ex->a_text));
elf_entry = interp_ex->a_entry; elf_entry = interp_ex->a_entry;
...@@ -318,7 +318,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -318,7 +318,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
return elf_exec_fileno; return elf_exec_fileno;
} }
file = current->filp[elf_exec_fileno]; file = current->files->fd[elf_exec_fileno];
elf_stack = 0xffffffff; elf_stack = 0xffffffff;
elf_interpreter = NULL; elf_interpreter = NULL;
...@@ -416,17 +416,17 @@ int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -416,17 +416,17 @@ int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
/* OK, This is the point of no return */ /* OK, This is the point of no return */
flush_old_exec(bprm); flush_old_exec(bprm);
current->end_data = 0; current->mm->end_data = 0;
current->end_code = 0; current->mm->end_code = 0;
current->start_mmap = ELF_START_MMAP; current->mm->start_mmap = ELF_START_MMAP;
current->mmap = NULL; current->mm->mmap = NULL;
elf_entry = (unsigned int) elf_ex.e_entry; elf_entry = (unsigned int) elf_ex.e_entry;
/* Do this so that we can load the interpreter, if need be. We will /* Do this so that we can load the interpreter, if need be. We will
change some of these later */ change some of these later */
current->rss = 0; current->mm->rss = 0;
bprm->p += change_ldt(0, bprm->page); bprm->p += change_ldt(0, bprm->page);
current->start_stack = bprm->p; current->mm->start_stack = bprm->p;
/* Now we do a little grungy work by mmaping the ELF image into /* Now we do a little grungy work by mmaping the ELF image into
the correct location in memory. At this point, we assume that the correct location in memory. At this point, we assume that
...@@ -512,18 +512,18 @@ int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -512,18 +512,18 @@ int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
load_addr, load_addr,
(interpreter_type == INTERPRETER_AOUT ? 0 : 1)); (interpreter_type == INTERPRETER_AOUT ? 0 : 1));
if(interpreter_type == INTERPRETER_AOUT) if(interpreter_type == INTERPRETER_AOUT)
current->arg_start += strlen(passed_fileno) + 1; current->mm->arg_start += strlen(passed_fileno) + 1;
current->start_brk = current->brk = elf_brk; current->mm->start_brk = current->mm->brk = elf_brk;
current->end_code = end_code; current->mm->end_code = end_code;
current->start_code = start_code; current->mm->start_code = start_code;
current->end_data = end_data; current->mm->end_data = end_data;
current->start_stack = bprm->p; current->mm->start_stack = bprm->p;
current->suid = current->euid = bprm->e_uid; current->suid = current->euid = bprm->e_uid;
current->sgid = current->egid = bprm->e_gid; current->sgid = current->egid = bprm->e_gid;
/* Calling sys_brk effectively mmaps the pages that we need for the bss and break /* Calling sys_brk effectively mmaps the pages that we need for the bss and break
sections */ sections */
current->brk = (elf_bss + 0xfff) & 0xfffff000; current->mm->brk = (elf_bss + 0xfff) & 0xfffff000;
sys_brk((elf_brk + 0xfff) & 0xfffff000); sys_brk((elf_brk + 0xfff) & 0xfffff000);
padzero(elf_bss); padzero(elf_bss);
...@@ -558,7 +558,7 @@ int load_elf_library(int fd){ ...@@ -558,7 +558,7 @@ int load_elf_library(int fd){
int i,j, k; int i,j, k;
len = 0; len = 0;
file = current->filp[fd]; file = current->files->fd[fd];
inode = file->f_inode; inode = file->f_inode;
elf_bss = 0; elf_bss = 0;
......
...@@ -254,7 +254,7 @@ asmlinkage int sys_fsync(unsigned int fd) ...@@ -254,7 +254,7 @@ asmlinkage int sys_fsync(unsigned int fd)
struct file * file; struct file * file;
struct inode * inode; struct inode * inode;
if (fd>=NR_OPEN || !(file=current->filp[fd]) || !(inode=file->f_inode)) if (fd>=NR_OPEN || !(file=current->files->fd[fd]) || !(inode=file->f_inode))
return -EBADF; return -EBADF;
if (!file->f_op || !file->f_op->fsync) if (!file->f_op || !file->f_op->fsync)
return -EINVAL; return -EINVAL;
...@@ -1096,7 +1096,7 @@ static unsigned long check_aligned(struct buffer_head * first, unsigned long add ...@@ -1096,7 +1096,7 @@ static unsigned long check_aligned(struct buffer_head * first, unsigned long add
while (nrbuf-- > 0) while (nrbuf-- > 0)
brelse(bh[nrbuf]); brelse(bh[nrbuf]);
free_page(address); free_page(address);
++current->min_flt; ++current->mm->min_flt;
return page; return page;
no_go: no_go:
while (nrbuf-- > 0) while (nrbuf-- > 0)
...@@ -1154,7 +1154,7 @@ static unsigned long try_to_load_aligned(unsigned long address, ...@@ -1154,7 +1154,7 @@ static unsigned long try_to_load_aligned(unsigned long address,
read_buffers(arr,block); read_buffers(arr,block);
while (block-- > 0) while (block-- > 0)
brelse(arr[block]); brelse(arr[block]);
++current->maj_flt; ++current->mm->maj_flt;
return address; return address;
not_aligned: not_aligned:
while ((tmp = bh) != NULL) { while ((tmp = bh) != NULL) {
...@@ -1213,7 +1213,7 @@ unsigned long bread_page(unsigned long address, dev_t dev, int b[], int size, in ...@@ -1213,7 +1213,7 @@ unsigned long bread_page(unsigned long address, dev_t dev, int b[], int size, in
if (where) if (where)
return where; return where;
} }
++current->maj_flt; ++current->mm->maj_flt;
for (i=0, j=0; j<PAGE_SIZE ; i++, j+= size) { for (i=0, j=0; j<PAGE_SIZE ; i++, j+= size) {
bh[i] = NULL; bh[i] = NULL;
if (b[i]) if (b[i])
......
...@@ -64,7 +64,7 @@ int open_inode(struct inode * inode, int mode) ...@@ -64,7 +64,7 @@ int open_inode(struct inode * inode, int mode)
if (!f) if (!f)
return -EMFILE; return -EMFILE;
fd = 0; fd = 0;
fpp = current->filp; fpp = current->files->fd;
for (;;) { for (;;) {
if (!*fpp) if (!*fpp)
break; break;
...@@ -164,8 +164,8 @@ int core_dump(long signr, struct pt_regs * regs) ...@@ -164,8 +164,8 @@ int core_dump(long signr, struct pt_regs * regs)
dump.magic = CMAGIC; dump.magic = CMAGIC;
dump.start_code = 0; dump.start_code = 0;
dump.start_stack = regs->esp & ~(PAGE_SIZE - 1); dump.start_stack = regs->esp & ~(PAGE_SIZE - 1);
dump.u_tsize = ((unsigned long) current->end_code) >> 12; dump.u_tsize = ((unsigned long) current->mm->end_code) >> 12;
dump.u_dsize = ((unsigned long) (current->brk + (PAGE_SIZE-1))) >> 12; dump.u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> 12;
dump.u_dsize -= dump.u_tsize; dump.u_dsize -= dump.u_tsize;
dump.u_ssize = 0; dump.u_ssize = 0;
for(i=0; i<8; i++) dump.u_debugreg[i] = current->debugreg[i]; for(i=0; i<8; i++) dump.u_debugreg[i] = current->debugreg[i];
...@@ -244,7 +244,7 @@ asmlinkage int sys_uselib(const char * library) ...@@ -244,7 +244,7 @@ asmlinkage int sys_uselib(const char * library)
fd = sys_open(library, 0, 0); fd = sys_open(library, 0, 0);
if (fd < 0) if (fd < 0)
return fd; return fd;
file = current->filp[fd]; file = current->files->fd[fd];
retval = -ENOEXEC; retval = -ENOEXEC;
if (file && file->f_inode && file->f_op && file->f_op->read) { if (file && file->f_inode && file->f_op && file->f_op->read) {
fmt = formats; fmt = formats;
...@@ -282,7 +282,7 @@ unsigned long * create_tables(char * p,int argc,int envc,int ibcs) ...@@ -282,7 +282,7 @@ unsigned long * create_tables(char * p,int argc,int envc,int ibcs)
mpnt->vm_offset = 0; mpnt->vm_offset = 0;
mpnt->vm_ops = NULL; mpnt->vm_ops = NULL;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
current->stk_vma = mpnt; current->mm->stk_vma = mpnt;
} }
sp = (unsigned long *) (0xfffffffc & (unsigned long) p); sp = (unsigned long *) (0xfffffffc & (unsigned long) p);
sp -= envc+1; sp -= envc+1;
...@@ -294,19 +294,19 @@ unsigned long * create_tables(char * p,int argc,int envc,int ibcs) ...@@ -294,19 +294,19 @@ unsigned long * create_tables(char * p,int argc,int envc,int ibcs)
put_fs_long((unsigned long)argv,--sp); put_fs_long((unsigned long)argv,--sp);
} }
put_fs_long((unsigned long)argc,--sp); put_fs_long((unsigned long)argc,--sp);
current->arg_start = (unsigned long) p; current->mm->arg_start = (unsigned long) p;
while (argc-->0) { while (argc-->0) {
put_fs_long((unsigned long) p,argv++); put_fs_long((unsigned long) p,argv++);
while (get_fs_byte(p++)) /* nothing */ ; while (get_fs_byte(p++)) /* nothing */ ;
} }
put_fs_long(0,argv); put_fs_long(0,argv);
current->arg_end = current->env_start = (unsigned long) p; current->mm->arg_end = current->mm->env_start = (unsigned long) p;
while (envc-->0) { while (envc-->0) {
put_fs_long((unsigned long) p,envp++); put_fs_long((unsigned long) p,envp++);
while (get_fs_byte(p++)) /* nothing */ ; while (get_fs_byte(p++)) /* nothing */ ;
} }
put_fs_long(0,envp); put_fs_long(0,envp);
current->env_end = (unsigned long) p; current->mm->env_end = (unsigned long) p;
return sp; return sp;
} }
...@@ -400,12 +400,12 @@ unsigned long change_ldt(unsigned long text_size,unsigned long * page) ...@@ -400,12 +400,12 @@ unsigned long change_ldt(unsigned long text_size,unsigned long * page)
code_limit = TASK_SIZE; code_limit = TASK_SIZE;
data_limit = TASK_SIZE; data_limit = TASK_SIZE;
code_base = data_base = 0; code_base = data_base = 0;
current->start_code = code_base; current->mm->start_code = code_base;
data_base += data_limit; data_base += data_limit;
for (i=MAX_ARG_PAGES-1 ; i>=0 ; i--) { for (i=MAX_ARG_PAGES-1 ; i>=0 ; i--) {
data_base -= PAGE_SIZE; data_base -= PAGE_SIZE;
if (page[i]) { if (page[i]) {
current->rss++; current->mm->rss++;
put_dirty_page(current,page[i],data_base); put_dirty_page(current,page[i],data_base);
} }
} }
...@@ -486,9 +486,9 @@ void flush_old_exec(struct linux_binprm * bprm) ...@@ -486,9 +486,9 @@ void flush_old_exec(struct linux_binprm * bprm)
} }
/* Release all of the old mmap stuff. */ /* Release all of the old mmap stuff. */
mpnt = current->mmap; mpnt = current->mm->mmap;
current->mmap = NULL; current->mm->mmap = NULL;
current->stk_vma = NULL; current->mm->stk_vma = NULL;
while (mpnt) { while (mpnt) {
mpnt1 = mpnt->vm_next; mpnt1 = mpnt->vm_next;
if (mpnt->vm_ops && mpnt->vm_ops->close) if (mpnt->vm_ops && mpnt->vm_ops->close)
...@@ -523,9 +523,9 @@ void flush_old_exec(struct linux_binprm * bprm) ...@@ -523,9 +523,9 @@ void flush_old_exec(struct linux_binprm * bprm)
current->sigaction[i].sa_handler = NULL; current->sigaction[i].sa_handler = NULL;
} }
for (i=0 ; i<NR_OPEN ; i++) for (i=0 ; i<NR_OPEN ; i++)
if (FD_ISSET(i,&current->close_on_exec)) if (FD_ISSET(i,&current->files->close_on_exec))
sys_close(i); sys_close(i);
FD_ZERO(&current->close_on_exec); FD_ZERO(&current->files->close_on_exec);
clear_page_tables(current); clear_page_tables(current);
if (last_task_used_math == current) if (last_task_used_math == current)
last_task_used_math = NULL; last_task_used_math = NULL;
...@@ -799,15 +799,15 @@ int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -799,15 +799,15 @@ int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
/* OK, This is the point of no return */ /* OK, This is the point of no return */
flush_old_exec(bprm); flush_old_exec(bprm);
current->end_code = N_TXTADDR(ex) + ex.a_text; current->mm->brk = ex.a_bss +
current->end_data = ex.a_data + current->end_code; (current->mm->start_brk =
current->start_brk = current->end_data; (current->mm->end_data = ex.a_data +
current->brk = current->start_brk + ex.a_bss; (current->mm->end_code = ex.a_text +
current->start_code += N_TXTADDR(ex); (current->mm->start_code = N_TXTADDR(ex)))));
current->rss = 0; current->mm->rss = 0;
current->suid = current->euid = bprm->e_uid; current->mm->mmap = NULL;
current->mmap = NULL;
current->executable = NULL; /* for OMAGIC files */ current->executable = NULL; /* for OMAGIC files */
current->suid = current->euid = bprm->e_uid;
current->sgid = current->egid = bprm->e_gid; current->sgid = current->egid = bprm->e_gid;
if (N_MAGIC(ex) == OMAGIC) { if (N_MAGIC(ex) == OMAGIC) {
do_mmap(NULL, 0, ex.a_text+ex.a_data, do_mmap(NULL, 0, ex.a_text+ex.a_data,
...@@ -822,7 +822,7 @@ int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -822,7 +822,7 @@ int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
if (fd < 0) if (fd < 0)
return fd; return fd;
file = current->filp[fd]; file = current->files->fd[fd];
if (!file->f_op || !file->f_op->mmap) { if (!file->f_op || !file->f_op->mmap) {
sys_close(fd); sys_close(fd);
do_mmap(NULL, 0, ex.a_text+ex.a_data, do_mmap(NULL, 0, ex.a_text+ex.a_data,
...@@ -854,12 +854,12 @@ int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) ...@@ -854,12 +854,12 @@ int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
bprm->inode->i_count++; bprm->inode->i_count++;
} }
beyond_if: beyond_if:
set_brk(current->start_brk, current->brk); set_brk(current->mm->start_brk, current->mm->brk);
p += change_ldt(ex.a_text,bprm->page); p += change_ldt(ex.a_text,bprm->page);
p -= MAX_ARG_PAGES*PAGE_SIZE; p -= MAX_ARG_PAGES*PAGE_SIZE;
p = (unsigned long) create_tables((char *)p,bprm->argc,bprm->envc,0); p = (unsigned long) create_tables((char *)p,bprm->argc,bprm->envc,0);
current->start_stack = p; current->mm->start_stack = p;
regs->eip = ex.a_entry; /* eip, magic happens :-) */ regs->eip = ex.a_entry; /* eip, magic happens :-) */
regs->esp = p; /* stack pointer */ regs->esp = p; /* stack pointer */
if (current->flags & PF_PTRACED) if (current->flags & PF_PTRACED)
...@@ -878,7 +878,7 @@ int load_aout_library(int fd) ...@@ -878,7 +878,7 @@ int load_aout_library(int fd)
unsigned int start_addr; unsigned int start_addr;
int error; int error;
file = current->filp[fd]; file = current->files->fd[fd];
inode = file->f_inode; inode = file->f_inode;
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
......
...@@ -447,7 +447,7 @@ int ext_mkdir(struct inode * dir, const char * name, int len, int mode) ...@@ -447,7 +447,7 @@ int ext_mkdir(struct inode * dir, const char * name, int len, int mode)
inode->i_nlink = 2; inode->i_nlink = 2;
mark_buffer_dirty(dir_block, 1); mark_buffer_dirty(dir_block, 1);
brelse(dir_block); brelse(dir_block);
inode->i_mode = S_IFDIR | (mode & 0777 & ~current->umask); inode->i_mode = S_IFDIR | (mode & 0777 & ~current->fs->umask);
if (dir->i_mode & S_ISGID) if (dir->i_mode & S_ISGID)
inode->i_mode |= S_ISGID; inode->i_mode |= S_ISGID;
inode->i_dirt = 1; inode->i_dirt = 1;
......
...@@ -52,7 +52,7 @@ static int ext_follow_link(struct inode * dir, struct inode * inode, ...@@ -52,7 +52,7 @@ static int ext_follow_link(struct inode * dir, struct inode * inode,
*res_inode = NULL; *res_inode = NULL;
if (!dir) { if (!dir) {
dir = current->root; dir = current->fs->root;
dir->i_count++; dir->i_count++;
} }
if (!inode) { if (!inode) {
......
...@@ -519,7 +519,7 @@ int ext2_mkdir (struct inode * dir, const char * name, int len, int mode) ...@@ -519,7 +519,7 @@ int ext2_mkdir (struct inode * dir, const char * name, int len, int mode)
inode->i_nlink = 2; inode->i_nlink = 2;
mark_buffer_dirty(dir_block, 1); mark_buffer_dirty(dir_block, 1);
brelse (dir_block); brelse (dir_block);
inode->i_mode = S_IFDIR | (mode & S_IRWXUGO & ~current->umask); inode->i_mode = S_IFDIR | (mode & S_IRWXUGO & ~current->fs->umask);
if (dir->i_mode & S_ISGID) if (dir->i_mode & S_ISGID)
inode->i_mode |= S_ISGID; inode->i_mode |= S_ISGID;
inode->i_dirt = 1; inode->i_dirt = 1;
......
...@@ -56,7 +56,7 @@ static int ext2_follow_link(struct inode * dir, struct inode * inode, ...@@ -56,7 +56,7 @@ static int ext2_follow_link(struct inode * dir, struct inode * inode,
*res_inode = NULL; *res_inode = NULL;
if (!dir) { if (!dir) {
dir = current->root; dir = current->fs->root;
dir->i_count++; dir->i_count++;
} }
if (!inode) { if (!inode) {
......
...@@ -19,25 +19,25 @@ extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg); ...@@ -19,25 +19,25 @@ extern int sock_fcntl (struct file *, unsigned int cmd, unsigned long arg);
static int dupfd(unsigned int fd, unsigned int arg) static int dupfd(unsigned int fd, unsigned int arg)
{ {
if (fd >= NR_OPEN || !current->filp[fd]) if (fd >= NR_OPEN || !current->files->fd[fd])
return -EBADF; return -EBADF;
if (arg >= NR_OPEN) if (arg >= NR_OPEN)
return -EINVAL; return -EINVAL;
while (arg < NR_OPEN) while (arg < NR_OPEN)
if (current->filp[arg]) if (current->files->fd[arg])
arg++; arg++;
else else
break; break;
if (arg >= NR_OPEN) if (arg >= NR_OPEN)
return -EMFILE; return -EMFILE;
FD_CLR(arg, &current->close_on_exec); FD_CLR(arg, &current->files->close_on_exec);
(current->filp[arg] = current->filp[fd])->f_count++; (current->files->fd[arg] = current->files->fd[fd])->f_count++;
return arg; return arg;
} }
asmlinkage int sys_dup2(unsigned int oldfd, unsigned int newfd) asmlinkage int sys_dup2(unsigned int oldfd, unsigned int newfd)
{ {
if (oldfd >= NR_OPEN || !current->filp[oldfd]) if (oldfd >= NR_OPEN || !current->files->fd[oldfd])
return -EBADF; return -EBADF;
if (newfd == oldfd) if (newfd == oldfd)
return newfd; return newfd;
...@@ -67,18 +67,18 @@ asmlinkage int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg) ...@@ -67,18 +67,18 @@ asmlinkage int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
{ {
struct file * filp; struct file * filp;
if (fd >= NR_OPEN || !(filp = current->filp[fd])) if (fd >= NR_OPEN || !(filp = current->files->fd[fd]))
return -EBADF; return -EBADF;
switch (cmd) { switch (cmd) {
case F_DUPFD: case F_DUPFD:
return dupfd(fd,arg); return dupfd(fd,arg);
case F_GETFD: case F_GETFD:
return FD_ISSET(fd, &current->close_on_exec); return FD_ISSET(fd, &current->files->close_on_exec);
case F_SETFD: case F_SETFD:
if (arg&1) if (arg&1)
FD_SET(fd, &current->close_on_exec); FD_SET(fd, &current->files->close_on_exec);
else else
FD_CLR(fd, &current->close_on_exec); FD_CLR(fd, &current->files->close_on_exec);
return 0; return 0;
case F_GETFL: case F_GETFL:
return filp->f_flags; return filp->f_flags;
......
...@@ -543,7 +543,7 @@ static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask, ...@@ -543,7 +543,7 @@ static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask,
*uid = current->uid; *uid = current->uid;
*gid = current->gid; *gid = current->gid;
*umask = current->umask; *umask = current->fs->umask;
*lowercase = 1; *lowercase = 1;
*conv = CONV_BINARY; *conv = CONV_BINARY;
......
...@@ -59,15 +59,15 @@ asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) ...@@ -59,15 +59,15 @@ asmlinkage int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
struct file * filp; struct file * filp;
int on; int on;
if (fd >= NR_OPEN || !(filp = current->filp[fd])) if (fd >= NR_OPEN || !(filp = current->files->fd[fd]))
return -EBADF; return -EBADF;
switch (cmd) { switch (cmd) {
case FIOCLEX: case FIOCLEX:
FD_SET(fd, &current->close_on_exec); FD_SET(fd, &current->files->close_on_exec);
return 0; return 0;
case FIONCLEX: case FIONCLEX:
FD_CLR(fd, &current->close_on_exec); FD_CLR(fd, &current->files->close_on_exec);
return 0; return 0;
case FIONBIO: case FIONBIO:
......
...@@ -49,7 +49,7 @@ static int isofs_follow_link(struct inode * dir, struct inode * inode, ...@@ -49,7 +49,7 @@ static int isofs_follow_link(struct inode * dir, struct inode * inode,
char * pnt; char * pnt;
if (!dir) { if (!dir) {
dir = current->root; dir = current->fs->root;
dir->i_count++; dir->i_count++;
} }
if (!inode) { if (!inode) {
......
...@@ -58,7 +58,7 @@ int fcntl_getlk(unsigned int fd, struct flock *l) ...@@ -58,7 +58,7 @@ int fcntl_getlk(unsigned int fd, struct flock *l)
struct file *filp; struct file *filp;
struct file_lock *fl,file_lock; struct file_lock *fl,file_lock;
if (fd >= NR_OPEN || !(filp = current->filp[fd])) if (fd >= NR_OPEN || !(filp = current->files->fd[fd]))
return -EBADF; return -EBADF;
error = verify_area(VERIFY_WRITE,l, sizeof(*l)); error = verify_area(VERIFY_WRITE,l, sizeof(*l));
if (error) if (error)
...@@ -102,7 +102,7 @@ int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l) ...@@ -102,7 +102,7 @@ int fcntl_setlk(unsigned int fd, unsigned int cmd, struct flock *l)
* Get arguments and validate them ... * Get arguments and validate them ...
*/ */
if (fd >= NR_OPEN || !(filp = current->filp[fd])) if (fd >= NR_OPEN || !(filp = current->files->fd[fd]))
return -EBADF; return -EBADF;
error = verify_area(VERIFY_WRITE, l, sizeof(*l)); error = verify_area(VERIFY_WRITE, l, sizeof(*l));
if (error) if (error)
......
...@@ -349,7 +349,7 @@ int minix_mkdir(struct inode * dir, const char * name, int len, int mode) ...@@ -349,7 +349,7 @@ int minix_mkdir(struct inode * dir, const char * name, int len, int mode)
inode->i_nlink = 2; inode->i_nlink = 2;
mark_buffer_dirty(dir_block, 1); mark_buffer_dirty(dir_block, 1);
brelse(dir_block); brelse(dir_block);
inode->i_mode = S_IFDIR | (mode & 0777 & ~current->umask); inode->i_mode = S_IFDIR | (mode & 0777 & ~current->fs->umask);
if (dir->i_mode & S_ISGID) if (dir->i_mode & S_ISGID)
inode->i_mode |= S_ISGID; inode->i_mode |= S_ISGID;
inode->i_dirt = 1; inode->i_dirt = 1;
......
...@@ -46,7 +46,7 @@ static int minix_follow_link(struct inode * dir, struct inode * inode, ...@@ -46,7 +46,7 @@ static int minix_follow_link(struct inode * dir, struct inode * inode,
*res_inode = NULL; *res_inode = NULL;
if (!dir) { if (!dir) {
dir = current->root; dir = current->fs->root;
dir->i_count++; dir->i_count++;
} }
if (!inode) { if (!inode) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/msdos_fs.h> #include <linux/msdos_fs.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h>
#include <linux/stat.h> #include <linux/stat.h>
......
...@@ -75,7 +75,7 @@ static int parse_options(char *options,char *check,char *conversion,uid_t *uid, ...@@ -75,7 +75,7 @@ static int parse_options(char *options,char *check,char *conversion,uid_t *uid,
*conversion = 'b'; *conversion = 'b';
*uid = current->uid; *uid = current->uid;
*gid = current->gid; *gid = current->gid;
*umask = current->umask; *umask = current->fs->umask;
*debug = *fat = *quiet = 0; *debug = *fat = *quiet = 0;
if (!options) return 1; if (!options) return 1;
for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) { for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
......
...@@ -103,7 +103,7 @@ int lookup(struct inode * dir,const char * name, int len, ...@@ -103,7 +103,7 @@ int lookup(struct inode * dir,const char * name, int len,
/* check permissions before traversing mount-points */ /* check permissions before traversing mount-points */
perm = permission(dir,MAY_EXEC); perm = permission(dir,MAY_EXEC);
if (len==2 && name[0] == '.' && name[1] == '.') { if (len==2 && name[0] == '.' && name[1] == '.') {
if (dir == current->root) { if (dir == current->fs->root) {
*result = dir; *result = dir;
return 0; return 0;
} else if ((sb = dir->i_sb) && (dir == sb->s_mounted)) { } else if ((sb = dir->i_sb) && (dir == sb->s_mounted)) {
...@@ -163,12 +163,12 @@ static int dir_namei(const char * pathname, int * namelen, const char ** name, ...@@ -163,12 +163,12 @@ static int dir_namei(const char * pathname, int * namelen, const char ** name,
*res_inode = NULL; *res_inode = NULL;
if (!base) { if (!base) {
base = current->pwd; base = current->fs->pwd;
base->i_count++; base->i_count++;
} }
if ((c = *pathname) == '/') { if ((c = *pathname) == '/') {
iput(base); iput(base);
base = current->root; base = current->fs->root;
pathname++; pathname++;
base->i_count++; base->i_count++;
} }
...@@ -279,7 +279,7 @@ int open_namei(const char * pathname, int flag, int mode, ...@@ -279,7 +279,7 @@ int open_namei(const char * pathname, int flag, int mode,
struct inode * dir, *inode; struct inode * dir, *inode;
struct task_struct ** p; struct task_struct ** p;
mode &= S_IALLUGO & ~current->umask; mode &= S_IALLUGO & ~current->fs->umask;
mode |= S_IFREG; mode |= S_IFREG;
error = dir_namei(pathname,&namelen,&basename,base,&dir); error = dir_namei(pathname,&namelen,&basename,base,&dir);
if (error) if (error)
...@@ -357,7 +357,7 @@ int open_namei(const char * pathname, int flag, int mode, ...@@ -357,7 +357,7 @@ int open_namei(const char * pathname, int flag, int mode,
iput(inode); iput(inode);
return -ETXTBSY; return -ETXTBSY;
} }
for(mpnt = (*p)->mmap; mpnt; mpnt = mpnt->vm_next) { for(mpnt = (*p)->mm->mmap; mpnt; mpnt = mpnt->vm_next) {
if (mpnt->vm_page_prot & PAGE_RW) if (mpnt->vm_page_prot & PAGE_RW)
continue; continue;
if (inode == mpnt->vm_inode) { if (inode == mpnt->vm_inode) {
...@@ -387,7 +387,7 @@ int do_mknod(const char * filename, int mode, dev_t dev) ...@@ -387,7 +387,7 @@ int do_mknod(const char * filename, int mode, dev_t dev)
int namelen, error; int namelen, error;
struct inode * dir; struct inode * dir;
mode &= ~current->umask; mode &= ~current->fs->umask;
error = dir_namei(filename,&namelen,&basename, NULL, &dir); error = dir_namei(filename,&namelen,&basename, NULL, &dir);
if (error) if (error)
return error; return error;
......
...@@ -77,7 +77,7 @@ struct super_block *nfs_read_super(struct super_block *sb, void *raw_data, ...@@ -77,7 +77,7 @@ struct super_block *nfs_read_super(struct super_block *sb, void *raw_data,
printk("nfs warning: mount version %s than kernel\n", printk("nfs warning: mount version %s than kernel\n",
data->version < NFS_MOUNT_VERSION ? "older" : "newer"); data->version < NFS_MOUNT_VERSION ? "older" : "newer");
} }
if (fd >= NR_OPEN || !(filp = current->filp[fd])) { if (fd >= NR_OPEN || !(filp = current->files->fd[fd])) {
printk("nfs_read_super: invalid file descriptor\n"); printk("nfs_read_super: invalid file descriptor\n");
sb->s_dev = 0; sb->s_dev = 0;
return NULL; return NULL;
......
...@@ -79,7 +79,7 @@ int nfs_mmap(struct inode * inode, struct file * file, ...@@ -79,7 +79,7 @@ int nfs_mmap(struct inode * inode, struct file * file,
mpnt->vm_offset = off; mpnt->vm_offset = off;
mpnt->vm_ops = &nfs_file_mmap; mpnt->vm_ops = &nfs_file_mmap;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
merge_segments(current->mmap, NULL, NULL); merge_segments(current->mm->mmap, NULL, NULL);
return 0; return 0;
} }
...@@ -101,11 +101,11 @@ static void nfs_file_mmap_nopage(int error_code, struct vm_area_struct * area, ...@@ -101,11 +101,11 @@ static void nfs_file_mmap_nopage(int error_code, struct vm_area_struct * area,
page = get_free_page(GFP_KERNEL); page = get_free_page(GFP_KERNEL);
if (share_page(area, area->vm_task, inode, address, error_code, page)) { if (share_page(area, area->vm_task, inode, address, error_code, page)) {
++area->vm_task->min_flt; ++area->vm_task->mm->min_flt;
return; return;
} }
++area->vm_task->maj_flt; ++area->vm_task->mm->maj_flt;
if (!page) { if (!page) {
oom(current); oom(current);
put_page(area->vm_task, BAD_PAGE, address, PAGE_PRIVATE); put_page(area->vm_task, BAD_PAGE, address, PAGE_PRIVATE);
......
...@@ -48,7 +48,7 @@ static int nfs_follow_link(struct inode *dir, struct inode *inode, ...@@ -48,7 +48,7 @@ static int nfs_follow_link(struct inode *dir, struct inode *inode,
*res_inode = NULL; *res_inode = NULL;
if (!dir) { if (!dir) {
dir = current->root; dir = current->fs->root;
dir->i_count++; dir->i_count++;
} }
if (!inode) { if (!inode) {
......
...@@ -55,7 +55,7 @@ asmlinkage int sys_fstatfs(unsigned int fd, struct statfs * buf) ...@@ -55,7 +55,7 @@ asmlinkage int sys_fstatfs(unsigned int fd, struct statfs * buf)
error = verify_area(VERIFY_WRITE, buf, sizeof(struct statfs)); error = verify_area(VERIFY_WRITE, buf, sizeof(struct statfs));
if (error) if (error)
return error; return error;
if (fd >= NR_OPEN || !(file = current->filp[fd])) if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF; return -EBADF;
if (!(inode = file->f_inode)) if (!(inode = file->f_inode))
return -ENOENT; return -ENOENT;
...@@ -96,7 +96,7 @@ asmlinkage int sys_ftruncate(unsigned int fd, unsigned int length) ...@@ -96,7 +96,7 @@ asmlinkage int sys_ftruncate(unsigned int fd, unsigned int length)
struct inode * inode; struct inode * inode;
struct file * file; struct file * file;
if (fd >= NR_OPEN || !(file = current->filp[fd])) if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF; return -EBADF;
if (!(inode = file->f_inode)) if (!(inode = file->f_inode))
return -ENOENT; return -ENOENT;
...@@ -205,8 +205,8 @@ asmlinkage int sys_chdir(const char * filename) ...@@ -205,8 +205,8 @@ asmlinkage int sys_chdir(const char * filename)
iput(inode); iput(inode);
return -EACCES; return -EACCES;
} }
iput(current->pwd); iput(current->fs->pwd);
current->pwd = inode; current->fs->pwd = inode;
return (0); return (0);
} }
...@@ -215,7 +215,7 @@ asmlinkage int sys_fchdir(unsigned int fd) ...@@ -215,7 +215,7 @@ asmlinkage int sys_fchdir(unsigned int fd)
struct inode * inode; struct inode * inode;
struct file * file; struct file * file;
if (fd >= NR_OPEN || !(file = current->filp[fd])) if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF; return -EBADF;
if (!(inode = file->f_inode)) if (!(inode = file->f_inode))
return -ENOENT; return -ENOENT;
...@@ -223,8 +223,8 @@ asmlinkage int sys_fchdir(unsigned int fd) ...@@ -223,8 +223,8 @@ asmlinkage int sys_fchdir(unsigned int fd)
return -ENOTDIR; return -ENOTDIR;
if (!permission(inode,MAY_EXEC)) if (!permission(inode,MAY_EXEC))
return -EACCES; return -EACCES;
iput(current->pwd); iput(current->fs->pwd);
current->pwd = inode; current->fs->pwd = inode;
inode->i_count++; inode->i_count++;
return (0); return (0);
} }
...@@ -245,8 +245,8 @@ asmlinkage int sys_chroot(const char * filename) ...@@ -245,8 +245,8 @@ asmlinkage int sys_chroot(const char * filename)
iput(inode); iput(inode);
return -EPERM; return -EPERM;
} }
iput(current->root); iput(current->fs->root);
current->root = inode; current->fs->root = inode;
return (0); return (0);
} }
...@@ -255,7 +255,7 @@ asmlinkage int sys_fchmod(unsigned int fd, mode_t mode) ...@@ -255,7 +255,7 @@ asmlinkage int sys_fchmod(unsigned int fd, mode_t mode)
struct inode * inode; struct inode * inode;
struct file * file; struct file * file;
if (fd >= NR_OPEN || !(file = current->filp[fd])) if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF; return -EBADF;
if (!(inode = file->f_inode)) if (!(inode = file->f_inode))
return -ENOENT; return -ENOENT;
...@@ -306,7 +306,7 @@ asmlinkage int sys_fchown(unsigned int fd, uid_t user, gid_t group) ...@@ -306,7 +306,7 @@ asmlinkage int sys_fchown(unsigned int fd, uid_t user, gid_t group)
struct inode * inode; struct inode * inode;
struct file * file; struct file * file;
if (fd >= NR_OPEN || !(file = current->filp[fd])) if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF; return -EBADF;
if (!(inode = file->f_inode)) if (!(inode = file->f_inode))
return -ENOENT; return -ENOENT;
...@@ -380,15 +380,15 @@ int do_open(const char * filename,int flags,int mode) ...@@ -380,15 +380,15 @@ int do_open(const char * filename,int flags,int mode)
int flag,error,fd; int flag,error,fd;
for(fd=0 ; fd<NR_OPEN ; fd++) for(fd=0 ; fd<NR_OPEN ; fd++)
if (!current->filp[fd]) if (!current->files->fd[fd])
break; break;
if (fd>=NR_OPEN) if (fd>=NR_OPEN)
return -EMFILE; return -EMFILE;
FD_CLR(fd,&current->close_on_exec); FD_CLR(fd,&current->files->close_on_exec);
f = get_empty_filp(); f = get_empty_filp();
if (!f) if (!f)
return -ENFILE; return -ENFILE;
current->filp[fd] = f; current->files->fd[fd] = f;
f->f_flags = flag = flags; f->f_flags = flag = flags;
f->f_mode = (flag+1) & O_ACCMODE; f->f_mode = (flag+1) & O_ACCMODE;
if (f->f_mode) if (f->f_mode)
...@@ -397,7 +397,7 @@ int do_open(const char * filename,int flags,int mode) ...@@ -397,7 +397,7 @@ int do_open(const char * filename,int flags,int mode)
flag |= 2; flag |= 2;
error = open_namei(filename,flag,mode,&inode,NULL); error = open_namei(filename,flag,mode,&inode,NULL);
if (error) { if (error) {
current->filp[fd]=NULL; current->files->fd[fd]=NULL;
f->f_count--; f->f_count--;
return error; return error;
} }
...@@ -413,7 +413,7 @@ int do_open(const char * filename,int flags,int mode) ...@@ -413,7 +413,7 @@ int do_open(const char * filename,int flags,int mode)
if (error) { if (error) {
iput(inode); iput(inode);
f->f_count--; f->f_count--;
current->filp[fd]=NULL; current->files->fd[fd]=NULL;
return error; return error;
} }
} }
...@@ -468,10 +468,10 @@ asmlinkage int sys_close(unsigned int fd) ...@@ -468,10 +468,10 @@ asmlinkage int sys_close(unsigned int fd)
if (fd >= NR_OPEN) if (fd >= NR_OPEN)
return -EBADF; return -EBADF;
FD_CLR(fd, &current->close_on_exec); FD_CLR(fd, &current->files->close_on_exec);
if (!(filp = current->filp[fd])) if (!(filp = current->files->fd[fd]))
return -EBADF; return -EBADF;
current->filp[fd] = NULL; current->files->fd[fd] = NULL;
return (close_fp (filp, fd)); return (close_fp (filp, fd));
} }
......
...@@ -394,20 +394,20 @@ asmlinkage int sys_pipe(unsigned long * fildes) ...@@ -394,20 +394,20 @@ asmlinkage int sys_pipe(unsigned long * fildes)
return -ENFILE; return -ENFILE;
j=0; j=0;
for(i=0;j<2 && i<NR_OPEN;i++) for(i=0;j<2 && i<NR_OPEN;i++)
if (!current->filp[i]) { if (!current->files->fd[i]) {
current->filp[ fd[j]=i ] = f[j]; current->files->fd[ fd[j]=i ] = f[j];
j++; j++;
} }
if (j==1) if (j==1)
current->filp[fd[0]]=NULL; current->files->fd[fd[0]]=NULL;
if (j<2) { if (j<2) {
f[0]->f_count--; f[0]->f_count--;
f[1]->f_count--; f[1]->f_count--;
return -EMFILE; return -EMFILE;
} }
if (!(inode=get_pipe_inode())) { if (!(inode=get_pipe_inode())) {
current->filp[fd[0]] = NULL; current->files->fd[fd[0]] = NULL;
current->filp[fd[1]] = NULL; current->files->fd[fd[1]] = NULL;
f[0]->f_count--; f[0]->f_count--;
f[1]->f_count--; f[1]->f_count--;
return -ENFILE; return -ENFILE;
......
...@@ -236,7 +236,7 @@ static int get_env(int pid, char * buffer) ...@@ -236,7 +236,7 @@ static int get_env(int pid, char * buffer)
if (!p || !*p) if (!p || !*p)
return 0; return 0;
return get_array(p, (*p)->env_start, (*p)->env_end, buffer); return get_array(p, (*p)->mm->env_start, (*p)->mm->env_end, buffer);
} }
static int get_arg(int pid, char * buffer) static int get_arg(int pid, char * buffer)
...@@ -245,7 +245,7 @@ static int get_arg(int pid, char * buffer) ...@@ -245,7 +245,7 @@ static int get_arg(int pid, char * buffer)
if (!p || !*p) if (!p || !*p)
return 0; return 0;
return get_array(p, (*p)->arg_start, (*p)->arg_end, buffer); return get_array(p, (*p)->mm->arg_start, (*p)->mm->arg_end, buffer);
} }
static unsigned long get_wchan(struct task_struct *p) static unsigned long get_wchan(struct task_struct *p)
...@@ -294,7 +294,7 @@ static int get_stat(int pid, char * buffer) ...@@ -294,7 +294,7 @@ static int get_stat(int pid, char * buffer)
if (vsize) { if (vsize) {
eip = KSTK_EIP(vsize); eip = KSTK_EIP(vsize);
esp = KSTK_ESP(vsize); esp = KSTK_ESP(vsize);
vsize = (*p)->brk - (*p)->start_code + PAGE_SIZE-1; vsize = (*p)->mm->brk - (*p)->mm->start_code + PAGE_SIZE-1;
if (esp) if (esp)
vsize += TASK_SIZE - esp; vsize += TASK_SIZE - esp;
} }
...@@ -312,7 +312,7 @@ static int get_stat(int pid, char * buffer) ...@@ -312,7 +312,7 @@ static int get_stat(int pid, char * buffer)
else else
tty_pgrp = -1; tty_pgrp = -1;
return sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ return sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
%lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %u %u %lu %lu %lu %lu %lu %lu \ %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %u %lu %lu %lu %lu %lu %lu \
%lu %lu %lu %lu\n", %lu %lu %lu %lu\n",
pid, pid,
(*p)->comm, (*p)->comm,
...@@ -323,10 +323,10 @@ static int get_stat(int pid, char * buffer) ...@@ -323,10 +323,10 @@ static int get_stat(int pid, char * buffer)
(*p)->tty, (*p)->tty,
tty_pgrp, tty_pgrp,
(*p)->flags, (*p)->flags,
(*p)->min_flt, (*p)->mm->min_flt,
(*p)->cmin_flt, (*p)->mm->cmin_flt,
(*p)->maj_flt, (*p)->mm->maj_flt,
(*p)->cmaj_flt, (*p)->mm->cmaj_flt,
(*p)->utime, (*p)->utime,
(*p)->stime, (*p)->stime,
(*p)->cutime, (*p)->cutime,
...@@ -339,11 +339,11 @@ static int get_stat(int pid, char * buffer) ...@@ -339,11 +339,11 @@ static int get_stat(int pid, char * buffer)
(*p)->it_real_value, (*p)->it_real_value,
(*p)->start_time, (*p)->start_time,
vsize, vsize,
(*p)->rss, /* you might want to shift this left 3 */ (*p)->mm->rss, /* you might want to shift this left 3 */
(*p)->rlim[RLIMIT_RSS].rlim_cur, (*p)->rlim[RLIMIT_RSS].rlim_cur,
(*p)->start_code, (*p)->mm->start_code,
(*p)->end_code, (*p)->mm->end_code,
(*p)->start_stack, (*p)->mm->start_stack,
esp, esp,
eip, eip,
(*p)->signal, (*p)->signal,
...@@ -362,7 +362,7 @@ static int get_statm(int pid, char * buffer) ...@@ -362,7 +362,7 @@ static int get_statm(int pid, char * buffer)
if (!p || !*p) if (!p || !*p)
return 0; return 0;
tpag = (*p)->end_code / PAGE_SIZE; tpag = (*p)->mm->end_code / PAGE_SIZE;
if ((*p)->state != TASK_ZOMBIE) { if ((*p)->state != TASK_ZOMBIE) {
pagedir = (unsigned long *) (*p)->tss.cr3; pagedir = (unsigned long *) (*p)->tss.cr3;
for (i = 0; i < 0x300; ++i) { for (i = 0; i < 0x300; ++i) {
...@@ -409,7 +409,7 @@ static int get_maps(int pid, char *buf) ...@@ -409,7 +409,7 @@ static int get_maps(int pid, char *buf)
if (!p || !*p) if (!p || !*p)
return 0; return 0;
for(map = (*p)->mmap; map != NULL; map = map->vm_next) { for(map = (*p)->mm->mmap; map != NULL; map = map->vm_next) {
char str[7], *cp = str; char str[7], *cp = str;
int prot = map->vm_page_prot; int prot = map->vm_page_prot;
int perms, flags; int perms, flags;
...@@ -466,6 +466,7 @@ static int get_maps(int pid, char *buf) ...@@ -466,6 +466,7 @@ static int get_maps(int pid, char *buf)
extern int get_module_list(char *); extern int get_module_list(char *);
extern int get_device_list(char *); extern int get_device_list(char *);
extern int get_filesystem_list(char *);
static int array_read(struct inode * inode, struct file * file,char * buf, int count) static int array_read(struct inode * inode, struct file * file,char * buf, int count)
{ {
...@@ -526,6 +527,9 @@ static int array_read(struct inode * inode, struct file * file,char * buf, int c ...@@ -526,6 +527,9 @@ static int array_read(struct inode * inode, struct file * file,char * buf, int c
case 18: case 18:
length = get_device_list(page); length = get_device_list(page);
break; break;
case 19:
length = get_filesystem_list(page);
break;
default: default:
free_page((unsigned long) page); free_page((unsigned long) page);
return -EBADF; return -EBADF;
......
...@@ -105,13 +105,13 @@ static int proc_lookupfd(struct inode * dir,const char * name, int len, ...@@ -105,13 +105,13 @@ static int proc_lookupfd(struct inode * dir,const char * name, int len,
if (!pid || i >= NR_TASKS) if (!pid || i >= NR_TASKS)
return -ENOENT; return -ENOENT;
if (!ino) { if (!ino) {
if (fd >= NR_OPEN || !p->filp[fd] || !p->filp[fd]->f_inode) if (fd >= NR_OPEN || !p->files->fd[fd] || !p->files->fd[fd]->f_inode)
return -ENOENT; return -ENOENT;
ino = (pid << 16) + 0x100 + fd; ino = (pid << 16) + 0x100 + fd;
} else { } else {
int j = 0; int j = 0;
struct vm_area_struct * mpnt; struct vm_area_struct * mpnt;
for (mpnt = p->mmap; mpnt; mpnt = mpnt->vm_next) for (mpnt = p->mm->mmap; mpnt; mpnt = mpnt->vm_next)
if (mpnt->vm_inode) if (mpnt->vm_inode)
j++; j++;
if (fd >= j) if (fd >= j)
...@@ -163,12 +163,12 @@ static int proc_readfd(struct inode * inode, struct file * filp, ...@@ -163,12 +163,12 @@ static int proc_readfd(struct inode * inode, struct file * filp,
if (!ino) { if (!ino) {
if (fd >= NR_OPEN) if (fd >= NR_OPEN)
break; break;
if (!p->filp[fd] || !p->filp[fd]->f_inode) if (!p->files->fd[fd] || !p->files->fd[fd]->f_inode)
continue; continue;
} else { } else {
int j = 0; int j = 0;
struct vm_area_struct * mpnt; struct vm_area_struct * mpnt;
for (mpnt = p->mmap ; mpnt ; mpnt = mpnt->vm_next) for (mpnt = p->mm->mmap ; mpnt ; mpnt = mpnt->vm_next)
if (mpnt->vm_inode) if (mpnt->vm_inode)
j++; j++;
if (fd >= j) if (fd >= j)
......
...@@ -169,7 +169,7 @@ void proc_read_inode(struct inode * inode) ...@@ -169,7 +169,7 @@ void proc_read_inode(struct inode * inode)
switch (ino >> 8) { switch (ino >> 8) {
case 1: case 1:
ino &= 0xff; ino &= 0xff;
if (ino >= NR_OPEN || !p->filp[ino]) if (ino >= NR_OPEN || !p->files->fd[ino])
return; return;
inode->i_op = &proc_link_inode_operations; inode->i_op = &proc_link_inode_operations;
inode->i_size = 64; inode->i_size = 64;
...@@ -180,7 +180,7 @@ void proc_read_inode(struct inode * inode) ...@@ -180,7 +180,7 @@ void proc_read_inode(struct inode * inode)
{ {
int j = 0; int j = 0;
struct vm_area_struct * mpnt; struct vm_area_struct * mpnt;
for (mpnt = p->mmap ; mpnt ; mpnt = mpnt->vm_next) for (mpnt = p->mm->mmap ; mpnt ; mpnt = mpnt->vm_next)
if(mpnt->vm_inode) if(mpnt->vm_inode)
j++; j++;
if (ino >= j) if (ino >= j)
......
...@@ -66,10 +66,10 @@ static int proc_follow_link(struct inode * dir, struct inode * inode, ...@@ -66,10 +66,10 @@ static int proc_follow_link(struct inode * dir, struct inode * inode,
inode = NULL; inode = NULL;
switch (ino) { switch (ino) {
case 4: case 4:
inode = p->pwd; inode = p->fs->pwd;
break; break;
case 5: case 5:
inode = p->root; inode = p->fs->root;
break; break;
case 6: case 6:
inode = p->executable; inode = p->executable;
...@@ -78,14 +78,14 @@ static int proc_follow_link(struct inode * dir, struct inode * inode, ...@@ -78,14 +78,14 @@ static int proc_follow_link(struct inode * dir, struct inode * inode,
switch (ino >> 8) { switch (ino >> 8) {
case 1: case 1:
ino &= 0xff; ino &= 0xff;
if (ino < NR_OPEN && p->filp[ino]) if (ino < NR_OPEN && p->files->fd[ino])
inode = p->filp[ino]->f_inode; inode = p->files->fd[ino]->f_inode;
break; break;
case 2: case 2:
ino &= 0xff; ino &= 0xff;
{ int j = ino; { int j = ino;
struct vm_area_struct * mpnt; struct vm_area_struct * mpnt;
for(mpnt = p->mmap; mpnt && j >= 0; for(mpnt = p->mm->mmap; mpnt && j >= 0;
mpnt = mpnt->vm_next){ mpnt = mpnt->vm_next){
if(mpnt->vm_inode) { if(mpnt->vm_inode) {
if(j == 0) { if(j == 0) {
......
...@@ -68,6 +68,7 @@ static struct proc_dir_entry root_dir[] = { ...@@ -68,6 +68,7 @@ static struct proc_dir_entry root_dir[] = {
{16,7,"modules" }, {16,7,"modules" },
{17,4,"stat" }, {17,4,"stat" },
{18,7,"devices" }, {18,7,"devices" },
{19,11,"filesystems" },
}; };
#define NR_ROOT_DIRENTRY ((sizeof (root_dir))/(sizeof (root_dir[0]))) #define NR_ROOT_DIRENTRY ((sizeof (root_dir))/(sizeof (root_dir[0])))
......
...@@ -22,7 +22,7 @@ asmlinkage int sys_readdir(unsigned int fd, struct dirent * dirent, unsigned int ...@@ -22,7 +22,7 @@ asmlinkage int sys_readdir(unsigned int fd, struct dirent * dirent, unsigned int
struct file * file; struct file * file;
struct inode * inode; struct inode * inode;
if (fd >= NR_OPEN || !(file = current->filp[fd]) || if (fd >= NR_OPEN || !(file = current->files->fd[fd]) ||
!(inode = file->f_inode)) !(inode = file->f_inode))
return -EBADF; return -EBADF;
error = -ENOTDIR; error = -ENOTDIR;
...@@ -39,7 +39,7 @@ asmlinkage int sys_lseek(unsigned int fd, off_t offset, unsigned int origin) ...@@ -39,7 +39,7 @@ asmlinkage int sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
struct file * file; struct file * file;
int tmp = -1; int tmp = -1;
if (fd >= NR_OPEN || !(file=current->filp[fd]) || !(file->f_inode)) if (fd >= NR_OPEN || !(file=current->files->fd[fd]) || !(file->f_inode))
return -EBADF; return -EBADF;
if (origin > 2) if (origin > 2)
return -EINVAL; return -EINVAL;
...@@ -73,7 +73,7 @@ asmlinkage int sys_read(unsigned int fd,char * buf,unsigned int count) ...@@ -73,7 +73,7 @@ asmlinkage int sys_read(unsigned int fd,char * buf,unsigned int count)
struct file * file; struct file * file;
struct inode * inode; struct inode * inode;
if (fd>=NR_OPEN || !(file=current->filp[fd]) || !(inode=file->f_inode)) if (fd>=NR_OPEN || !(file=current->files->fd[fd]) || !(inode=file->f_inode))
return -EBADF; return -EBADF;
if (!(file->f_mode & 1)) if (!(file->f_mode & 1))
return -EBADF; return -EBADF;
...@@ -93,7 +93,7 @@ asmlinkage int sys_write(unsigned int fd,char * buf,unsigned int count) ...@@ -93,7 +93,7 @@ asmlinkage int sys_write(unsigned int fd,char * buf,unsigned int count)
struct file * file; struct file * file;
struct inode * inode; struct inode * inode;
if (fd>=NR_OPEN || !(file=current->filp[fd]) || !(inode=file->f_inode)) if (fd>=NR_OPEN || !(file=current->files->fd[fd]) || !(inode=file->f_inode))
return -EBADF; return -EBADF;
if (!(file->f_mode & 2)) if (!(file->f_mode & 2))
return -EBADF; return -EBADF;
......
...@@ -95,9 +95,9 @@ static int do_select(int n, fd_set *in, fd_set *out, fd_set *ex, ...@@ -95,9 +95,9 @@ static int do_select(int n, fd_set *in, fd_set *out, fd_set *ex,
goto end_check; goto end_check;
if (!(set & 1)) if (!(set & 1))
continue; continue;
if (!current->filp[i]) if (!current->files->fd[i])
return -EBADF; return -EBADF;
if (!current->filp[i]->f_inode) if (!current->files->fd[i]->f_inode)
return -EBADF; return -EBADF;
max = i; max = i;
} }
...@@ -116,17 +116,17 @@ static int do_select(int n, fd_set *in, fd_set *out, fd_set *ex, ...@@ -116,17 +116,17 @@ static int do_select(int n, fd_set *in, fd_set *out, fd_set *ex,
repeat: repeat:
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
for (i = 0 ; i < n ; i++) { for (i = 0 ; i < n ; i++) {
if (FD_ISSET(i,in) && check(SEL_IN,wait,current->filp[i])) { if (FD_ISSET(i,in) && check(SEL_IN,wait,current->files->fd[i])) {
FD_SET(i, res_in); FD_SET(i, res_in);
count++; count++;
wait = NULL; wait = NULL;
} }
if (FD_ISSET(i,out) && check(SEL_OUT,wait,current->filp[i])) { if (FD_ISSET(i,out) && check(SEL_OUT,wait,current->files->fd[i])) {
FD_SET(i, res_out); FD_SET(i, res_out);
count++; count++;
wait = NULL; wait = NULL;
} }
if (FD_ISSET(i,ex) && check(SEL_EX,wait,current->filp[i])) { if (FD_ISSET(i,ex) && check(SEL_EX,wait,current->files->fd[i])) {
FD_SET(i, res_ex); FD_SET(i, res_ex);
count++; count++;
wait = NULL; wait = NULL;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -33,9 +34,10 @@ static void cp_old_stat(struct inode * inode, struct old_stat * statbuf) ...@@ -33,9 +34,10 @@ static void cp_old_stat(struct inode * inode, struct old_stat * statbuf)
static void cp_new_stat(struct inode * inode, struct new_stat * statbuf) static void cp_new_stat(struct inode * inode, struct new_stat * statbuf)
{ {
struct new_stat tmp = {0, }; struct new_stat tmp;
unsigned int blocks, indirect; unsigned int blocks, indirect;
memset(&tmp, 0, sizeof(tmp));
tmp.st_dev = inode->i_dev; tmp.st_dev = inode->i_dev;
tmp.st_ino = inode->i_ino; tmp.st_ino = inode->i_ino;
tmp.st_mode = inode->i_mode; tmp.st_mode = inode->i_mode;
...@@ -159,7 +161,7 @@ asmlinkage int sys_fstat(unsigned int fd, struct old_stat * statbuf) ...@@ -159,7 +161,7 @@ asmlinkage int sys_fstat(unsigned int fd, struct old_stat * statbuf)
error = verify_area(VERIFY_WRITE,statbuf,sizeof (*statbuf)); error = verify_area(VERIFY_WRITE,statbuf,sizeof (*statbuf));
if (error) if (error)
return error; return error;
if (fd >= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode)) if (fd >= NR_OPEN || !(f=current->files->fd[fd]) || !(inode=f->f_inode))
return -EBADF; return -EBADF;
cp_old_stat(inode,statbuf); cp_old_stat(inode,statbuf);
return 0; return 0;
...@@ -174,7 +176,7 @@ asmlinkage int sys_newfstat(unsigned int fd, struct new_stat * statbuf) ...@@ -174,7 +176,7 @@ asmlinkage int sys_newfstat(unsigned int fd, struct new_stat * statbuf)
error = verify_area(VERIFY_WRITE,statbuf,sizeof (*statbuf)); error = verify_area(VERIFY_WRITE,statbuf,sizeof (*statbuf));
if (error) if (error)
return error; return error;
if (fd >= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode)) if (fd >= NR_OPEN || !(f=current->files->fd[fd]) || !(inode=f->f_inode))
return -EBADF; return -EBADF;
cp_new_stat(inode,statbuf); cp_new_stat(inode,statbuf);
return 0; return 0;
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
/* /*
* super.c contains code to handle the super-block tables. * super.c contains code to handle the super-block tables.
*/ */
#include <stdarg.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -71,6 +73,101 @@ int unregister_filesystem(struct file_system_type * fs) ...@@ -71,6 +73,101 @@ int unregister_filesystem(struct file_system_type * fs)
return -EINVAL; return -EINVAL;
} }
static int fs_index(const char * __name)
{
struct file_system_type * tmp;
char * name;
int err, index;
err = getname(__name, &name);
if (err)
return err;
index = 0;
for (tmp = file_systems ; tmp ; tmp = tmp->next) {
if (strcmp(tmp->name, name) == 0) {
putname(name);
return index;
}
index++;
}
putname(name);
return -EINVAL;
}
static int fs_name(unsigned int index, char * buf)
{
struct file_system_type * tmp;
int err, len;
tmp = file_systems;
while (tmp && index > 0) {
tmp = tmp->next;
index--;
}
if (!tmp)
return -EINVAL;
len = strlen(tmp->name) + 1;
err = verify_area(VERIFY_WRITE, buf, len);
if (err)
return err;
memcpy_tofs(buf, tmp->name, len);
return 0;
}
static int fs_maxindex(void)
{
struct file_system_type * tmp;
int index;
index = 0;
for (tmp = file_systems ; tmp ; tmp = tmp->next)
index++;
return index;
}
/*
* Whee.. Weird sysv syscall.
*/
asmlinkage int sys_sysfs(int option, ...)
{
va_list args;
int retval = -EINVAL;
unsigned int index;
va_start(args, option);
switch (option) {
case 1:
retval = fs_index(va_arg(args, const char *));
break;
case 2:
index = va_arg(args, unsigned int);
retval = fs_name(index, va_arg(args, char *));
break;
case 3:
retval = fs_maxindex();
break;
}
va_end(args);
return retval;
}
int get_filesystem_list(char * buf)
{
int len = 0;
struct file_system_type * tmp;
tmp = file_systems;
while (tmp && len < PAGE_SIZE - 80) {
len += sprintf(buf+len, "%s\t%s\n",
tmp->requires_dev ? "" : "nodev",
tmp->name);
tmp = tmp->next;
}
return len;
}
struct file_system_type *get_fs_type(char *name) struct file_system_type *get_fs_type(char *name)
{ {
struct file_system_type * fs = file_systems; struct file_system_type * fs = file_systems;
...@@ -422,7 +519,7 @@ static int copy_mount_options (const void * data, unsigned long *where) ...@@ -422,7 +519,7 @@ static int copy_mount_options (const void * data, unsigned long *where)
if (!data) if (!data)
return 0; return 0;
for (vma = current->mmap ; ; ) { for (vma = current->mm->mmap ; ; ) {
if (!vma || if (!vma ||
(unsigned long) data < vma->vm_start) { (unsigned long) data < vma->vm_start) {
return -EFAULT; return -EFAULT;
...@@ -557,8 +654,8 @@ void mount_root(void) ...@@ -557,8 +654,8 @@ void mount_root(void)
inode->i_count += 3 ; /* NOTE! it is logically used 4 times, not 1 */ inode->i_count += 3 ; /* NOTE! it is logically used 4 times, not 1 */
sb->s_covered = inode; sb->s_covered = inode;
sb->s_flags = root_mountflags; sb->s_flags = root_mountflags;
current->pwd = inode; current->fs->pwd = inode;
current->root = inode; current->fs->root = inode;
printk ("VFS: Mounted root (%s filesystem)%s.\n", printk ("VFS: Mounted root (%s filesystem)%s.\n",
fs_type->name, fs_type->name,
(sb->s_flags & MS_RDONLY) ? " readonly" : ""); (sb->s_flags & MS_RDONLY) ? " readonly" : "");
......
...@@ -351,7 +351,7 @@ int sysv_mkdir(struct inode * dir, const char * name, int len, int mode) ...@@ -351,7 +351,7 @@ int sysv_mkdir(struct inode * dir, const char * name, int len, int mode)
inode->i_nlink = 2; inode->i_nlink = 2;
mark_buffer_dirty(dir_block, 1); mark_buffer_dirty(dir_block, 1);
brelse(dir_block); brelse(dir_block);
inode->i_mode = S_IFDIR | (mode & 0777 & ~current->umask); inode->i_mode = S_IFDIR | (mode & 0777 & ~current->fs->umask);
if (dir->i_mode & S_ISGID) if (dir->i_mode & S_ISGID)
inode->i_mode |= S_ISGID; inode->i_mode |= S_ISGID;
inode->i_dirt = 1; inode->i_dirt = 1;
......
...@@ -53,7 +53,7 @@ static int sysv_follow_link(struct inode * dir, struct inode * inode, ...@@ -53,7 +53,7 @@ static int sysv_follow_link(struct inode * dir, struct inode * inode,
*res_inode = NULL; *res_inode = NULL;
if (!dir) { if (!dir) {
dir = current->root; dir = current->fs->root;
dir->i_count++; dir->i_count++;
} }
if (!inode) { if (!inode) {
......
...@@ -377,7 +377,7 @@ int xiafs_mkdir(struct inode * dir, const char * name, int len, int mode) ...@@ -377,7 +377,7 @@ int xiafs_mkdir(struct inode * dir, const char * name, int len, int mode)
inode->i_nlink = 2; inode->i_nlink = 2;
mark_buffer_dirty(dir_block, 1); mark_buffer_dirty(dir_block, 1);
brelse(dir_block); brelse(dir_block);
inode->i_mode = S_IFDIR | (mode & S_IRWXUGO & ~current->umask); inode->i_mode = S_IFDIR | (mode & S_IRWXUGO & ~current->fs->umask);
if (dir->i_mode & S_ISGID) if (dir->i_mode & S_ISGID)
inode->i_mode |= S_ISGID; inode->i_mode |= S_ISGID;
inode->i_dirt = 1; inode->i_dirt = 1;
......
...@@ -80,7 +80,7 @@ static int xiafs_follow_link(struct inode * dir, struct inode * inode, ...@@ -80,7 +80,7 @@ static int xiafs_follow_link(struct inode * dir, struct inode * inode,
*res_inode = NULL; *res_inode = NULL;
if (!dir) { if (!dir) {
dir = current->root; dir = current->fs->root;
dir->i_count++; dir->i_count++;
} }
if (!inode) { if (!inode) {
......
...@@ -172,6 +172,75 @@ struct tss_struct { ...@@ -172,6 +172,75 @@ struct tss_struct {
union i387_union i387; union i387_union i387;
}; };
#define INIT_TSS { \
0,0, \
sizeof(init_kernel_stack) + (long) &init_kernel_stack, \
KERNEL_DS, 0, \
0,0,0,0,0,0, \
(long) &swapper_pg_dir, \
0,0,0,0,0,0,0,0,0,0, \
USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0, \
_LDT(0),0, \
0, 0x8000, \
{~0, }, /* ioperm */ \
_TSS(0), 0, 0,0, \
{ { 0, }, } /* 387 state */ \
}
struct files_struct {
int count;
fd_set close_on_exec;
struct file * fd[NR_OPEN];
};
#define INIT_FILES { \
0, \
{ { 0, } }, \
{ NULL, } \
}
struct fs_struct {
int count;
unsigned short umask;
struct inode * root, * pwd;
};
#define INIT_FS { \
0, \
0022, \
NULL, NULL \
}
struct mm_struct {
int count;
unsigned long start_code, end_code, end_data;
unsigned long start_brk, brk, start_stack, start_mmap;
unsigned long arg_start, arg_end, env_start, env_end;
unsigned long rss;
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
int swappable:1;
#ifdef NEW_SWAP
unsigned long old_maj_flt; /* old value of maj_flt */
unsigned long dec_flt; /* page fault count of the last time */
unsigned long swap_cnt; /* number of pages to swap on next pass */
short swap_table; /* current page table */
short swap_page; /* current page */
#endif NEW_SWAP
struct vm_area_struct * mmap;
struct vm_area_struct * stk_vma;
};
#define INIT_MM { \
0, \
0, 0, 0, \
0, 0, 0, 0, \
0, 0, 0, 0, \
0, \
/* ?_flt */ 0, 0, 0, 0, \
0, \
/* swap */ 0, 0, 0, 0, 0, \
NULL, NULL }
struct task_struct { struct task_struct {
/* these are hardcoded - don't touch */ /* these are hardcoded - don't touch */
volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
...@@ -190,10 +259,7 @@ struct task_struct { ...@@ -190,10 +259,7 @@ struct task_struct {
int exit_code, exit_signal; int exit_code, exit_signal;
int elf_executable:1; int elf_executable:1;
int dumpable:1; int dumpable:1;
int swappable:1;
int did_exec:1; int did_exec:1;
unsigned long start_code,end_code,end_data,start_brk,brk,start_stack,start_mmap;
unsigned long arg_start, arg_end, env_start, env_end;
int pid,pgrp,session,leader; int pid,pgrp,session,leader;
int groups[NGROUPS]; int groups[NGROUPS];
/* /*
...@@ -201,23 +267,16 @@ struct task_struct { ...@@ -201,23 +267,16 @@ struct task_struct {
* older sibling, respectively. (p->father can be replaced with * older sibling, respectively. (p->father can be replaced with
* p->p_pptr->pid) * p->p_pptr->pid)
*/ */
struct task_struct *p_opptr,*p_pptr, *p_cptr, *p_ysptr, *p_osptr; struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr;
struct wait_queue *wait_chldexit; /* for wait4() */ struct wait_queue *wait_chldexit; /* for wait4() */
/*
* For ease of programming... Normal sleeps don't need to
* keep track of a wait-queue: every task has an entry of its own
*/
unsigned short uid,euid,suid; unsigned short uid,euid,suid;
unsigned short gid,egid,sgid; unsigned short gid,egid,sgid;
unsigned long timeout; unsigned long timeout;
unsigned long it_real_value, it_prof_value, it_virt_value; unsigned long it_real_value, it_prof_value, it_virt_value;
unsigned long it_real_incr, it_prof_incr, it_virt_incr; unsigned long it_real_incr, it_prof_incr, it_virt_incr;
long utime,stime,cutime,cstime,start_time; long utime, stime, cutime, cstime, start_time;
unsigned long min_flt, maj_flt;
unsigned long cmin_flt, cmaj_flt;
struct rlimit rlim[RLIM_NLIMITS]; struct rlimit rlim[RLIM_NLIMITS];
unsigned short used_math; unsigned short used_math;
unsigned short rss; /* number of resident pages */
char comm[16]; char comm[16];
/* virtual 86 mode stuff */ /* virtual 86 mode stuff */
struct vm86_struct * vm86_info; struct vm86_struct * vm86_info;
...@@ -226,27 +285,19 @@ struct task_struct { ...@@ -226,27 +285,19 @@ struct task_struct {
/* file system info */ /* file system info */
int link_count; int link_count;
int tty; /* -1 if no tty, so it must be signed */ int tty; /* -1 if no tty, so it must be signed */
unsigned short umask;
struct inode * pwd;
struct inode * root;
struct inode * executable; struct inode * executable;
struct vm_area_struct * mmap;
struct shm_desc *shm; struct shm_desc *shm;
struct sem_undo *semun; struct sem_undo *semun;
struct file * filp[NR_OPEN];
fd_set close_on_exec;
/* ldt for this task - used by Wine. If NULL, default_ldt is used */ /* ldt for this task - used by Wine. If NULL, default_ldt is used */
struct desc_struct *ldt; struct desc_struct *ldt;
/* tss for this task */ /* tss for this task */
struct tss_struct tss; struct tss_struct tss;
#ifdef NEW_SWAP /* filesystem information */
unsigned long old_maj_flt; /* old value of maj_flt */ struct fs_struct fs[1];
unsigned long dec_flt; /* page fault count of the last time */ /* open file information */
unsigned long swap_cnt; /* number of pages to swap on next pass */ struct files_struct files[1];
short swap_table; /* current page table */ /* memory management info */
short swap_page; /* current page */ struct mm_struct mm[1];
#endif NEW_SWAP
struct vm_area_struct *stk_vma;
}; };
/* /*
...@@ -274,38 +325,25 @@ struct task_struct { ...@@ -274,38 +325,25 @@ struct task_struct {
/* schedlink */ &init_task,&init_task, \ /* schedlink */ &init_task,&init_task, \
/* signals */ {{ 0, },}, \ /* signals */ {{ 0, },}, \
/* stack */ 0,(unsigned long) &init_kernel_stack, \ /* stack */ 0,(unsigned long) &init_kernel_stack, \
/* ec,brk... */ 0,0,0,0,0,0,0,0,0,0,0,0,0, \ /* ec,brk... */ 0,0,0,0,0, \
/* argv.. */ 0,0,0,0, \
/* pid etc.. */ 0,0,0,0, \ /* pid etc.. */ 0,0,0,0, \
/* suppl grps*/ {NOGROUP,}, \ /* suppl grps*/ {NOGROUP,}, \
/* proc links*/ &init_task,&init_task,NULL,NULL,NULL,NULL, \ /* proc links*/ &init_task,&init_task,NULL,NULL,NULL,NULL, \
/* uid etc */ 0,0,0,0,0,0, \ /* uid etc */ 0,0,0,0,0,0, \
/* timeout */ 0,0,0,0,0,0,0,0,0,0,0,0, \ /* timeout */ 0,0,0,0,0,0,0,0,0,0,0,0, \
/* min_flt */ 0,0,0,0, \
/* rlimits */ { {LONG_MAX, LONG_MAX}, {LONG_MAX, LONG_MAX}, \ /* rlimits */ { {LONG_MAX, LONG_MAX}, {LONG_MAX, LONG_MAX}, \
{LONG_MAX, LONG_MAX}, {LONG_MAX, LONG_MAX}, \ {LONG_MAX, LONG_MAX}, {LONG_MAX, LONG_MAX}, \
{ 0, LONG_MAX}, {LONG_MAX, LONG_MAX}}, \ { 0, LONG_MAX}, {LONG_MAX, LONG_MAX}}, \
/* math */ 0, \ /* math */ 0, \
/* rss */ 2, \
/* comm */ "swapper", \ /* comm */ "swapper", \
/* vm86_info */ NULL, 0, 0, 0, 0, \ /* vm86_info */ NULL, 0, 0, 0, 0, \
/* fs info */ 0,-1,0022,NULL,NULL,NULL,NULL, \ /* fs info */ 0,-1,NULL, \
/* ipc */ NULL, NULL, \ /* ipc */ NULL, NULL, \
/* filp */ {NULL,}, \
/* cloe */ {{ 0, }}, \
/* ldt */ NULL, \ /* ldt */ NULL, \
/*tss*/ {0,0, \ /* tss */ INIT_TSS, \
sizeof(init_kernel_stack) + (long) &init_kernel_stack, KERNEL_DS, 0, \ /* fs */ { INIT_FS }, \
0,0,0,0,0,0, \ /* files */ { INIT_FILES }, \
(long) &swapper_pg_dir, \ /* mm */ { INIT_MM } \
0,0,0,0,0,0,0,0,0,0, \
USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0, \
_LDT(0),0, \
0, 0x8000, \
/* ioperm */ {~0, }, \
_TSS(0), 0, 0,0, \
/* 387 state */ { { 0, }, } \
} \
} }
extern struct task_struct init_task; extern struct task_struct init_task;
......
...@@ -141,6 +141,7 @@ ...@@ -141,6 +141,7 @@
#define __NR_getpgid 132 #define __NR_getpgid 132
#define __NR_fchdir 133 #define __NR_fchdir 133
#define __NR_bdflush 134 #define __NR_bdflush 134
#define __NR_sysfs 135
extern int errno; extern int errno;
......
...@@ -102,6 +102,7 @@ struct vm86_struct { ...@@ -102,6 +102,7 @@ struct vm86_struct {
#ifdef __KERNEL__ #ifdef __KERNEL__
void handle_vm86_fault(struct vm86_regs *, long); void handle_vm86_fault(struct vm86_regs *, long);
void handle_vm86_debug(struct vm86_regs *, long);
#endif #endif
......
...@@ -344,7 +344,7 @@ static int shm_map (struct shm_desc *shmd, int remap) ...@@ -344,7 +344,7 @@ static int shm_map (struct shm_desc *shmd, int remap)
if (!remap) if (!remap)
return -EINVAL; return -EINVAL;
if (*page_table & PAGE_PRESENT) { if (*page_table & PAGE_PRESENT) {
--current->rss; --current->mm->rss;
free_page (*page_table & PAGE_MASK); free_page (*page_table & PAGE_MASK);
} }
else else
...@@ -419,7 +419,7 @@ int sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr) ...@@ -419,7 +419,7 @@ int sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr)
else else
return -EINVAL; return -EINVAL;
} }
if ((addr > current->start_stack - 16384 - PAGE_SIZE*shp->shm_npages)) if ((addr > current->mm->start_stack - 16384 - PAGE_SIZE*shp->shm_npages))
return -EINVAL; return -EINVAL;
if (shmflg & SHM_REMAP) if (shmflg & SHM_REMAP)
for (shmd = current->shm; shmd; shmd = shmd->task_next) { for (shmd = current->shm; shmd; shmd = shmd->task_next) {
...@@ -449,7 +449,7 @@ int sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr) ...@@ -449,7 +449,7 @@ int sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *raddr)
shmd->task = current; shmd->task = current;
shp->shm_nattch++; /* prevent destruction */ shp->shm_nattch++; /* prevent destruction */
if (addr < current->end_data) { if (addr < current->mm->end_data) {
iput (current->executable); iput (current->executable);
current->executable = NULL; current->executable = NULL;
/* current->end_data = current->end_code = 0; */ /* current->end_data = current->end_code = 0; */
...@@ -626,10 +626,10 @@ void shm_no_page (unsigned long *ptent) ...@@ -626,10 +626,10 @@ void shm_no_page (unsigned long *ptent)
shm_rss++; shm_rss++;
shp->shm_pages[idx] = page | (PAGE_SHARED | PAGE_DIRTY); shp->shm_pages[idx] = page | (PAGE_SHARED | PAGE_DIRTY);
} else } else
--current->maj_flt; /* was incremented in do_no_page */ --current->mm->maj_flt; /* was incremented in do_no_page */
done: done:
current->min_flt++; current->mm->min_flt++;
page = shp->shm_pages[idx]; page = shp->shm_pages[idx];
if (code & SHM_READ_ONLY) /* write-protect */ if (code & SHM_READ_ONLY) /* write-protect */
page &= ~2; page &= ~2;
...@@ -717,7 +717,7 @@ int shm_swap (int prio) ...@@ -717,7 +717,7 @@ int shm_swap (int prio)
tmp = shmd->shm_sgn | idx << SHM_IDX_SHIFT; tmp = shmd->shm_sgn | idx << SHM_IDX_SHIFT;
*pte = tmp; *pte = tmp;
mem_map[MAP_NR(page)]--; mem_map[MAP_NR(page)]--;
shmd->task->rss--; shmd->task->mm->rss--;
invalid++; invalid++;
} }
......
...@@ -350,33 +350,18 @@ static void forget_original_parent(struct task_struct * father) ...@@ -350,33 +350,18 @@ static void forget_original_parent(struct task_struct * father)
} }
} }
NORET_TYPE void do_exit(long code) static void exit_mm(void)
{ {
struct task_struct *p; struct vm_area_struct * mpnt;
int i;
mpnt = current->mm->mmap;
if (intr_count) { current->mm->mmap = NULL;
printk("Aiee, killing interrupt handler\n"); while (mpnt) {
intr_count = 0; struct vm_area_struct * next = mpnt->vm_next;
} if (mpnt->vm_ops && mpnt->vm_ops->close)
fake_volatile: mpnt->vm_ops->close(mpnt);
if (current->semun) kfree(mpnt);
sem_exit(); mpnt = next;
if (current->shm)
shm_exit();
/* Release all of the old mmap stuff. */
{
struct vm_area_struct * mpnt, *mpnt1;
mpnt = current->mmap;
current->mmap = NULL;
while (mpnt) {
mpnt1 = mpnt->vm_next;
if (mpnt->vm_ops && mpnt->vm_ops->close)
mpnt->vm_ops->close(mpnt);
kfree(mpnt);
mpnt = mpnt1;
}
} }
/* forget local segments */ /* forget local segments */
...@@ -391,16 +376,44 @@ NORET_TYPE void do_exit(long code) ...@@ -391,16 +376,44 @@ NORET_TYPE void do_exit(long code)
} }
free_page_tables(current); free_page_tables(current);
}
static void exit_files(void)
{
int i;
for (i=0 ; i<NR_OPEN ; i++) for (i=0 ; i<NR_OPEN ; i++)
if (current->filp[i]) if (current->files->fd[i])
sys_close(i); sys_close(i);
forget_original_parent(current); }
iput(current->pwd);
current->pwd = NULL; static void exit_fs(void)
iput(current->root); {
current->root = NULL; iput(current->fs->pwd);
current->fs->pwd = NULL;
iput(current->fs->root);
current->fs->root = NULL;
iput(current->executable); iput(current->executable);
current->executable = NULL; current->executable = NULL;
}
NORET_TYPE void do_exit(long code)
{
struct task_struct *p;
if (intr_count) {
printk("Aiee, killing interrupt handler\n");
intr_count = 0;
}
fake_volatile:
if (current->semun)
sem_exit();
if (current->shm)
shm_exit();
exit_mm();
exit_files();
exit_fs();
forget_original_parent(current);
/* /*
* Check to see if any process groups have become orphaned * Check to see if any process groups have become orphaned
* as a result of our exiting, and if they have any stopped * as a result of our exiting, and if they have any stopped
...@@ -461,7 +474,7 @@ NORET_TYPE void do_exit(long code) ...@@ -461,7 +474,7 @@ NORET_TYPE void do_exit(long code)
last_task_used_math = NULL; last_task_used_math = NULL;
current->state = TASK_ZOMBIE; current->state = TASK_ZOMBIE;
current->exit_code = code; current->exit_code = code;
current->rss = 0; current->mm->rss = 0;
#ifdef DEBUG_PROC_TREE #ifdef DEBUG_PROC_TREE
audit_ptree(); audit_ptree();
#endif #endif
...@@ -533,8 +546,8 @@ asmlinkage int sys_wait4(pid_t pid,unsigned long * stat_addr, int options, struc ...@@ -533,8 +546,8 @@ asmlinkage int sys_wait4(pid_t pid,unsigned long * stat_addr, int options, struc
case TASK_ZOMBIE: case TASK_ZOMBIE:
current->cutime += p->utime + p->cutime; current->cutime += p->utime + p->cutime;
current->cstime += p->stime + p->cstime; current->cstime += p->stime + p->cstime;
current->cmin_flt += p->min_flt + p->cmin_flt; current->mm->cmin_flt += p->mm->min_flt + p->mm->cmin_flt;
current->cmaj_flt += p->maj_flt + p->cmaj_flt; current->mm->cmaj_flt += p->mm->maj_flt + p->mm->cmaj_flt;
if (ru != NULL) if (ru != NULL)
getrusage(p, RUSAGE_BOTH, ru); getrusage(p, RUSAGE_BOTH, ru);
flag = p->pid; flag = p->pid;
......
...@@ -89,14 +89,14 @@ static struct file * copy_fd(struct file * old_file) ...@@ -89,14 +89,14 @@ static struct file * copy_fd(struct file * old_file)
return new_file; return new_file;
} }
int dup_mmap(struct task_struct * tsk) static int dup_mmap(struct task_struct * tsk)
{ {
struct vm_area_struct * mpnt, **p, *tmp; struct vm_area_struct * mpnt, **p, *tmp;
tsk->mmap = NULL; tsk->mm->mmap = NULL;
tsk->stk_vma = NULL; tsk->mm->stk_vma = NULL;
p = &tsk->mmap; p = &tsk->mm->mmap;
for (mpnt = current->mmap ; mpnt ; mpnt = mpnt->vm_next) { for (mpnt = current->mm->mmap ; mpnt ; mpnt = mpnt->vm_next) {
tmp = (struct vm_area_struct *) kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL); tmp = (struct vm_area_struct *) kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
if (!tmp) if (!tmp)
return -ENOMEM; return -ENOMEM;
...@@ -107,14 +107,63 @@ int dup_mmap(struct task_struct * tsk) ...@@ -107,14 +107,63 @@ int dup_mmap(struct task_struct * tsk)
tmp->vm_inode->i_count++; tmp->vm_inode->i_count++;
*p = tmp; *p = tmp;
p = &tmp->vm_next; p = &tmp->vm_next;
if (current->stk_vma == mpnt) if (current->mm->stk_vma == mpnt)
tsk->stk_vma = tmp; tsk->mm->stk_vma = tmp;
} }
return 0; return 0;
} }
/*
* SHAREFD not yet implemented..
*/
static void copy_files(unsigned long clone_flags, struct task_struct * p)
{
int i;
struct file * f;
if (clone_flags & COPYFD) {
for (i=0; i<NR_OPEN;i++)
if ((f = p->files->fd[i]) != NULL)
p->files->fd[i] = copy_fd(f);
} else {
for (i=0; i<NR_OPEN;i++)
if ((f = p->files->fd[i]) != NULL)
f->f_count++;
}
}
/*
* CLONEVM not yet correctly implemented: needs to clone the mmap
* instead of duplicating it..
*/
static int copy_mm(unsigned long clone_flags, struct task_struct * p)
{
if (clone_flags & COPYVM) {
p->mm->swappable = 1;
p->mm->min_flt = p->mm->maj_flt = 0;
p->mm->cmin_flt = p->mm->cmaj_flt = 0;
if (copy_page_tables(p))
return 1;
dup_mmap(p);
} else {
if (clone_page_tables(p))
return 1;
dup_mmap(p); /* wrong.. */
}
return 0;
}
static void copy_fs(unsigned long clone_flags, struct task_struct * p)
{
if (current->fs->pwd)
current->fs->pwd->i_count++;
if (current->fs->root)
current->fs->root->i_count++;
if (current->executable)
current->executable->i_count++;
}
#define IS_CLONE (regs.orig_eax == __NR_clone) #define IS_CLONE (regs.orig_eax == __NR_clone)
#define copy_vm(p) ((clone_flags & COPYVM)?copy_page_tables(p):clone_page_tables(p))
/* /*
* Ok, this is the main fork-routine. It copies the system process * Ok, this is the main fork-routine. It copies the system process
...@@ -126,7 +175,6 @@ asmlinkage int sys_fork(struct pt_regs regs) ...@@ -126,7 +175,6 @@ asmlinkage int sys_fork(struct pt_regs regs)
struct pt_regs * childregs; struct pt_regs * childregs;
struct task_struct *p; struct task_struct *p;
int i,nr; int i,nr;
struct file *f;
unsigned long clone_flags = COPYVM | SIGCHLD; unsigned long clone_flags = COPYVM | SIGCHLD;
if(!(p = (struct task_struct*)__get_free_page(GFP_KERNEL))) if(!(p = (struct task_struct*)__get_free_page(GFP_KERNEL)))
...@@ -141,7 +189,6 @@ asmlinkage int sys_fork(struct pt_regs regs) ...@@ -141,7 +189,6 @@ asmlinkage int sys_fork(struct pt_regs regs)
p->state = TASK_UNINTERRUPTIBLE; p->state = TASK_UNINTERRUPTIBLE;
p->flags &= ~(PF_PTRACED|PF_TRACESYS); p->flags &= ~(PF_PTRACED|PF_TRACESYS);
p->pid = last_pid; p->pid = last_pid;
p->swappable = 1;
p->p_pptr = p->p_opptr = current; p->p_pptr = p->p_opptr = current;
p->p_cptr = NULL; p->p_cptr = NULL;
SET_LINKS(p); SET_LINKS(p);
...@@ -151,8 +198,6 @@ asmlinkage int sys_fork(struct pt_regs regs) ...@@ -151,8 +198,6 @@ asmlinkage int sys_fork(struct pt_regs regs)
p->leader = 0; /* process leadership doesn't inherit */ p->leader = 0; /* process leadership doesn't inherit */
p->utime = p->stime = 0; p->utime = p->stime = 0;
p->cutime = p->cstime = 0; p->cutime = p->cstime = 0;
p->min_flt = p->maj_flt = 0;
p->cmin_flt = p->cmaj_flt = 0;
p->start_time = jiffies; p->start_time = jiffies;
/* /*
* set up new TSS and kernel stack * set up new TSS and kernel stack
...@@ -196,24 +241,10 @@ asmlinkage int sys_fork(struct pt_regs regs) ...@@ -196,24 +241,10 @@ asmlinkage int sys_fork(struct pt_regs regs)
if (last_task_used_math == current) if (last_task_used_math == current)
__asm__("clts ; fnsave %0 ; frstor %0":"=m" (p->tss.i387)); __asm__("clts ; fnsave %0 ; frstor %0":"=m" (p->tss.i387));
p->semun = NULL; p->shm = NULL; p->semun = NULL; p->shm = NULL;
if (copy_vm(p) || shm_fork(current, p)) if (copy_mm(clone_flags, p) || shm_fork(current, p))
goto bad_fork_cleanup; goto bad_fork_cleanup;
if (clone_flags & COPYFD) { copy_files(clone_flags, p);
for (i=0; i<NR_OPEN;i++) copy_fs(clone_flags, p);
if ((f = p->filp[i]) != NULL)
p->filp[i] = copy_fd(f);
} else {
for (i=0; i<NR_OPEN;i++)
if ((f = p->filp[i]) != NULL)
f->f_count++;
}
if (current->pwd)
current->pwd->i_count++;
if (current->root)
current->root->i_count++;
if (current->executable)
current->executable->i_count++;
dup_mmap(p);
set_tss_desc(gdt+(nr<<1)+FIRST_TSS_ENTRY,&(p->tss)); set_tss_desc(gdt+(nr<<1)+FIRST_TSS_ENTRY,&(p->tss));
if (p->ldt) if (p->ldt)
set_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY,p->ldt, 512); set_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY,p->ldt, 512);
......
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/malloc.h> #include <linux/malloc.h>
#include <linux/binfmts.h>
#include <linux/ptrace.h>
#include <linux/sys.h>
#include <linux/utsname.h>
extern void *sys_call_table;
#define X(name) { (void *) &name, "_" #name } #define X(name) { (void *) &name, "_" #name }
...@@ -18,12 +24,30 @@ extern char * ftape_big_buffer; ...@@ -18,12 +24,30 @@ extern char * ftape_big_buffer;
extern void (*do_floppy)(void); extern void (*do_floppy)(void);
#endif #endif
#ifdef CONFIG_BINFMT_IBCS
extern int do_execve(char * filename, char ** argv, char ** envp,
struct pt_regs * regs);
extern void flush_old_exec(struct linux_binprm * bprm);
extern int open_inode(struct inode * inode, int mode);
extern int read_exec(struct inode *inode, unsigned long offset,
char * addr, unsigned long count);
extern void check_pending(int signum);
extern int do_signal(unsigned long oldmask, struct pt_regs * regs);
extern int (*ibcs_invmapsig)(int);
extern void (* iABI_hook)(struct pt_regs * regs);
#endif
struct { struct {
void *addr; void *addr;
const char *name; const char *name;
} symbol_table[] = { } symbol_table[] = {
/* process memory management */ /* system info variables */
X(EISA_bus),
X(wp_works_ok), X(wp_works_ok),
/* process memory management */
X(__verify_write), X(__verify_write),
X(do_mmap), X(do_mmap),
X(do_munmap), X(do_munmap),
...@@ -50,6 +74,10 @@ struct { ...@@ -50,6 +74,10 @@ struct {
X(register_blkdev), X(register_blkdev),
X(unregister_blkdev), X(unregister_blkdev),
/* filesystem registration */
X(register_filesystem),
X(unregister_filesystem),
/* interrupt handling */ /* interrupt handling */
X(request_irq), X(request_irq),
X(free_irq), X(free_irq),
...@@ -66,12 +94,44 @@ struct { ...@@ -66,12 +94,44 @@ struct {
X(printk), X(printk),
X(sprintf), X(sprintf),
X(vsprintf), X(vsprintf),
X(system_utsname),
X(sys_call_table),
#ifdef CONFIG_FTAPE #ifdef CONFIG_FTAPE
/* The next labels are needed for ftape driver. */ /* The next labels are needed for ftape driver. */
X(ftape_big_buffer), X(ftape_big_buffer),
X(do_floppy), X(do_floppy),
#endif #endif
#ifdef CONFIG_BINFMT_IBCS
/*
* The following are needed if iBCS support is modular rather than
* compiled in.
*/
/* Emulator hooks. */
X(iABI_hook),
X(ibcs_invmapsig),
/* Signal interfaces */
X(do_signal),
X(check_pending),
X(send_sig),
/* Program loader interfaces */
X(change_ldt),
X(copy_strings),
X(create_tables),
X(do_execve),
X(flush_old_exec),
X(formats),
X(insert_vm_struct),
X(open_inode),
X(read_exec),
X(zeromap_page_range),
/* Miscellaneous access points */
X(si_meminfo),
#endif
}; };
int symbol_table_size = sizeof (symbol_table) / sizeof (symbol_table[0]); int symbol_table_size = sizeof (symbol_table) / sizeof (symbol_table[0]);
...@@ -190,11 +190,15 @@ void ctrl_alt_del(void) ...@@ -190,11 +190,15 @@ void ctrl_alt_del(void)
/* /*
* This is done BSD-style, with no consideration of the saved gid, except * Unprivileged users may change the real gid to the effective gid
* that if you set the effective gid, it sets the saved gid too. This * or vice versa. (BSD-style)
* makes it possible for a setgid program to completely drop its privileges, *
* which is often a useful assertion to make when you are doing a security * If you set the real gid at all, or set the effective gid to a value not
* audit over a program. * equal to the real gid, then the saved gid is set to the new effective gid.
*
* This makes it possible for a setgid program to completely drop its
* privileges, which is often a useful assertion to make when you are doing
* a security audit over a program.
* *
* The general idea is that a program which uses just setregid() will be * The general idea is that a program which uses just setregid() will be
* 100% compatible with BSD. A program which uses just setgid() will be * 100% compatible with BSD. A program which uses just setgid() will be
...@@ -215,14 +219,16 @@ asmlinkage int sys_setregid(gid_t rgid, gid_t egid) ...@@ -215,14 +219,16 @@ asmlinkage int sys_setregid(gid_t rgid, gid_t egid)
if (egid != (gid_t) -1) { if (egid != (gid_t) -1) {
if ((old_rgid == egid) || if ((old_rgid == egid) ||
(current->egid == egid) || (current->egid == egid) ||
suser()) { suser())
current->egid = egid; current->egid = egid;
current->sgid = egid; else {
} else {
current->gid = old_rgid; current->gid = old_rgid;
return(-EPERM); return(-EPERM);
} }
} }
if (rgid != (gid_t) -1 ||
egid != (gid_t) -1 && egid != old_rgid)
current->sgid = current->egid;
return 0; return 0;
} }
...@@ -271,13 +277,15 @@ asmlinkage int sys_old_syscall(void) ...@@ -271,13 +277,15 @@ asmlinkage int sys_old_syscall(void)
} }
/* /*
* Unprivileged users may change the real user id to the effective uid * Unprivileged users may change the real uid to the effective uid
* or vice versa. (BSD-style) * or vice versa. (BSD-style)
* *
* When you set the effective uid, it sets the saved uid too. This * If you set the real uid at all, or set the effective uid to a value not
* makes it possible for a setuid program to completely drop its privileges, * equal to the real uid, then the saved uid is set to the new effective uid.
* which is often a useful assertion to make when you are doing a security *
* audit over a program. * This makes it possible for a setuid program to completely drop its
* privileges, which is often a useful assertion to make when you are doing
* a security audit over a program.
* *
* The general idea is that a program which uses just setreuid() will be * The general idea is that a program which uses just setreuid() will be
* 100% compatible with BSD. A program which uses just setuid() will be * 100% compatible with BSD. A program which uses just setuid() will be
...@@ -286,10 +294,10 @@ asmlinkage int sys_old_syscall(void) ...@@ -286,10 +294,10 @@ asmlinkage int sys_old_syscall(void)
asmlinkage int sys_setreuid(uid_t ruid, uid_t euid) asmlinkage int sys_setreuid(uid_t ruid, uid_t euid)
{ {
int old_ruid = current->uid; int old_ruid = current->uid;
if (ruid != (uid_t) -1) { if (ruid != (uid_t) -1) {
if ((current->euid==ruid) || if ((current->euid==ruid) ||
(old_ruid == ruid) || (old_ruid == ruid) ||
suser()) suser())
current->uid = ruid; current->uid = ruid;
else else
...@@ -298,14 +306,16 @@ asmlinkage int sys_setreuid(uid_t ruid, uid_t euid) ...@@ -298,14 +306,16 @@ asmlinkage int sys_setreuid(uid_t ruid, uid_t euid)
if (euid != (uid_t) -1) { if (euid != (uid_t) -1) {
if ((old_ruid == euid) || if ((old_ruid == euid) ||
(current->euid == euid) || (current->euid == euid) ||
suser()) { suser())
current->euid = euid; current->euid = euid;
current->suid = euid; else {
} else {
current->uid = old_ruid; current->uid = old_ruid;
return(-EPERM); return(-EPERM);
} }
} }
if (ruid != (uid_t) -1 ||
euid != (uid_t) -1 && euid != old_ruid)
current->suid = current->euid;
return 0; return 0;
} }
...@@ -351,18 +361,18 @@ asmlinkage int sys_brk(unsigned long brk) ...@@ -351,18 +361,18 @@ asmlinkage int sys_brk(unsigned long brk)
unsigned long rlim; unsigned long rlim;
unsigned long newbrk, oldbrk; unsigned long newbrk, oldbrk;
if (brk < current->end_code) if (brk < current->mm->end_code)
return current->brk; return current->mm->brk;
newbrk = PAGE_ALIGN(brk); newbrk = PAGE_ALIGN(brk);
oldbrk = PAGE_ALIGN(current->brk); oldbrk = PAGE_ALIGN(current->mm->brk);
if (oldbrk == newbrk) if (oldbrk == newbrk)
return current->brk = brk; return current->mm->brk = brk;
/* /*
* Always allow shrinking brk * Always allow shrinking brk
*/ */
if (brk <= current->brk) { if (brk <= current->mm->brk) {
current->brk = brk; current->mm->brk = brk;
do_munmap(newbrk, oldbrk-newbrk); do_munmap(newbrk, oldbrk-newbrk);
return brk; return brk;
} }
...@@ -372,8 +382,9 @@ asmlinkage int sys_brk(unsigned long brk) ...@@ -372,8 +382,9 @@ asmlinkage int sys_brk(unsigned long brk)
rlim = current->rlim[RLIMIT_DATA].rlim_cur; rlim = current->rlim[RLIMIT_DATA].rlim_cur;
if (rlim >= RLIM_INFINITY) if (rlim >= RLIM_INFINITY)
rlim = ~0; rlim = ~0;
if (brk - current->end_code > rlim || brk >= current->start_stack - 16384) if (brk - current->mm->end_code > rlim ||
return current->brk; brk >= current->mm->start_stack - 16384)
return current->mm->brk;
/* /*
* stupid algorithm to decide if we have enough memory: while * stupid algorithm to decide if we have enough memory: while
* simple, it hopefully works in most obvious cases.. Easy to * simple, it hopefully works in most obvious cases.. Easy to
...@@ -385,17 +396,17 @@ asmlinkage int sys_brk(unsigned long brk) ...@@ -385,17 +396,17 @@ asmlinkage int sys_brk(unsigned long brk)
freepages -= (high_memory - 0x100000) >> 16; freepages -= (high_memory - 0x100000) >> 16;
freepages -= (newbrk-oldbrk) >> 12; freepages -= (newbrk-oldbrk) >> 12;
if (freepages < 0) if (freepages < 0)
return current->brk; return current->mm->brk;
#if 0 #if 0
freepages += current->rss; freepages += current->mm->rss;
freepages -= oldbrk >> 12; freepages -= oldbrk >> 12;
if (freepages < 0) if (freepages < 0)
return current->brk; return current->mm->brk;
#endif #endif
/* /*
* Ok, we have probably got enough memory - let it rip. * Ok, we have probably got enough memory - let it rip.
*/ */
current->brk = brk; current->mm->brk = brk;
do_mmap(NULL, oldbrk, newbrk-oldbrk, do_mmap(NULL, oldbrk, newbrk-oldbrk,
PROT_READ|PROT_WRITE|PROT_EXEC, PROT_READ|PROT_WRITE|PROT_EXEC,
MAP_FIXED|MAP_PRIVATE, 0); MAP_FIXED|MAP_PRIVATE, 0);
...@@ -688,24 +699,24 @@ int getrusage(struct task_struct *p, int who, struct rusage *ru) ...@@ -688,24 +699,24 @@ int getrusage(struct task_struct *p, int who, struct rusage *ru)
r.ru_utime.tv_usec = CT_TO_USECS(p->utime); r.ru_utime.tv_usec = CT_TO_USECS(p->utime);
r.ru_stime.tv_sec = CT_TO_SECS(p->stime); r.ru_stime.tv_sec = CT_TO_SECS(p->stime);
r.ru_stime.tv_usec = CT_TO_USECS(p->stime); r.ru_stime.tv_usec = CT_TO_USECS(p->stime);
r.ru_minflt = p->min_flt; r.ru_minflt = p->mm->min_flt;
r.ru_majflt = p->maj_flt; r.ru_majflt = p->mm->maj_flt;
break; break;
case RUSAGE_CHILDREN: case RUSAGE_CHILDREN:
r.ru_utime.tv_sec = CT_TO_SECS(p->cutime); r.ru_utime.tv_sec = CT_TO_SECS(p->cutime);
r.ru_utime.tv_usec = CT_TO_USECS(p->cutime); r.ru_utime.tv_usec = CT_TO_USECS(p->cutime);
r.ru_stime.tv_sec = CT_TO_SECS(p->cstime); r.ru_stime.tv_sec = CT_TO_SECS(p->cstime);
r.ru_stime.tv_usec = CT_TO_USECS(p->cstime); r.ru_stime.tv_usec = CT_TO_USECS(p->cstime);
r.ru_minflt = p->cmin_flt; r.ru_minflt = p->mm->cmin_flt;
r.ru_majflt = p->cmaj_flt; r.ru_majflt = p->mm->cmaj_flt;
break; break;
default: default:
r.ru_utime.tv_sec = CT_TO_SECS(p->utime + p->cutime); r.ru_utime.tv_sec = CT_TO_SECS(p->utime + p->cutime);
r.ru_utime.tv_usec = CT_TO_USECS(p->utime + p->cutime); r.ru_utime.tv_usec = CT_TO_USECS(p->utime + p->cutime);
r.ru_stime.tv_sec = CT_TO_SECS(p->stime + p->cstime); r.ru_stime.tv_sec = CT_TO_SECS(p->stime + p->cstime);
r.ru_stime.tv_usec = CT_TO_USECS(p->stime + p->cstime); r.ru_stime.tv_usec = CT_TO_USECS(p->stime + p->cstime);
r.ru_minflt = p->min_flt + p->cmin_flt; r.ru_minflt = p->mm->min_flt + p->mm->cmin_flt;
r.ru_majflt = p->maj_flt + p->cmaj_flt; r.ru_majflt = p->mm->maj_flt + p->mm->cmaj_flt;
break; break;
} }
lp = (unsigned long *) &r; lp = (unsigned long *) &r;
...@@ -725,8 +736,8 @@ asmlinkage int sys_getrusage(int who, struct rusage *ru) ...@@ -725,8 +736,8 @@ asmlinkage int sys_getrusage(int who, struct rusage *ru)
asmlinkage int sys_umask(int mask) asmlinkage int sys_umask(int mask)
{ {
int old = current->umask; int old = current->fs->umask;
current->umask = mask & S_IRWXUGO; current->fs->umask = mask & S_IRWXUGO;
return (old); return (old);
} }
...@@ -531,5 +531,6 @@ _sys_call_table: ...@@ -531,5 +531,6 @@ _sys_call_table:
.long _sys_getpgid .long _sys_getpgid
.long _sys_fchdir .long _sys_fchdir
.long _sys_bdflush .long _sys_bdflush
.long _sys_sysfs /* 135 */
.space (NR_syscalls-130)*4 .space (NR_syscalls-135)*4
...@@ -148,20 +148,22 @@ asmlinkage void do_nmi(struct pt_regs * regs, long error_code) ...@@ -148,20 +148,22 @@ asmlinkage void do_nmi(struct pt_regs * regs, long error_code)
asmlinkage void do_debug(struct pt_regs * regs, long error_code) asmlinkage void do_debug(struct pt_regs * regs, long error_code)
{ {
if (regs->eflags & VM_MASK) {
handle_vm86_debug((struct vm86_regs *) regs, error_code);
return;
}
if (current->flags & PF_PTRACED) if (current->flags & PF_PTRACED)
current->blocked &= ~(1 << (SIGTRAP-1)); current->blocked &= ~(1 << (SIGTRAP-1));
send_sig(SIGTRAP, current, 1); send_sig(SIGTRAP, current, 1);
current->tss.trap_no = 1; current->tss.trap_no = 1;
current->tss.error_code = error_code; current->tss.error_code = error_code;
if((regs->cs & 3) == 0) { if ((regs->cs & 3) == 0) {
/* If this is a kernel mode trap, then reset db7 and allow us to continue */ /* If this is a kernel mode trap, then reset db7 and allow us to continue */
__asm__("movl $0,%%edx\n\t" \ __asm__("movl %0,%%db7"
"movl %%edx,%%db7\n\t" \ : /* no output */
: /* no output */ \ : "r" (0));
: /* no input */ :"dx"); return;
}
return;
};
die_if_kernel("debug",regs,error_code); die_if_kernel("debug",regs,error_code);
} }
......
...@@ -14,8 +14,25 @@ ...@@ -14,8 +14,25 @@
#include <asm/io.h> #include <asm/io.h>
/* /*
* 16-bit register defines.. * Known problems:
*
* Interrupt handling is not guaranteed:
* - a real x86 will disable all interrupts for one instruction
* after a "mov ss,xx" to make stack handling atomic even without
* the 'lss' instruction. We can't guarantee this in v86 mode,
* as the next instruction might result in a page fault or similar.
* - a real x86 will have interrupts disabled for one instruction
* past the 'sti' that enables them. We don't bother with all the
* details yet..
*
* Hopefully these problems do not actually matter for anything.
*/ */
/*
* 8- and 16-bit register defines..
*/
#define AL(regs) (((unsigned char *) ((regs)->eax))[0])
#define AH(regs) (((unsigned char *) ((regs)->eax))[1])
#define IP(regs) (*(unsigned short *)&((regs)->eip)) #define IP(regs) (*(unsigned short *)&((regs)->eip))
#define SP(regs) (*(unsigned short *)&((regs)->esp)) #define SP(regs) (*(unsigned short *)&((regs)->esp))
...@@ -272,7 +289,7 @@ static void do_int(struct vm86_regs *regs, int i, unsigned char * ssp, unsigned ...@@ -272,7 +289,7 @@ static void do_int(struct vm86_regs *regs, int i, unsigned char * ssp, unsigned
if (seg == BIOSSEG || regs->cs == BIOSSEG || if (seg == BIOSSEG || regs->cs == BIOSSEG ||
is_revectored(i, &current->vm86_info->int_revectored)) is_revectored(i, &current->vm86_info->int_revectored))
return_to_32bit(regs, VM86_INTx + (i << 8)); return_to_32bit(regs, VM86_INTx + (i << 8));
if (i==0x21 && is_revectored((regs->eax >> 4) & 0xff,&current->vm86_info->int21_revectored)) { if (i==0x21 && is_revectored(AH(regs),&current->vm86_info->int21_revectored)) {
return_to_32bit(regs, VM86_INTx + (i << 8)); return_to_32bit(regs, VM86_INTx + (i << 8));
} }
pushw(ssp, sp, get_vflags(regs)); pushw(ssp, sp, get_vflags(regs));
...@@ -286,6 +303,10 @@ static void do_int(struct vm86_regs *regs, int i, unsigned char * ssp, unsigned ...@@ -286,6 +303,10 @@ static void do_int(struct vm86_regs *regs, int i, unsigned char * ssp, unsigned
return; return;
} }
void handle_vm86_debug(struct vm86_regs * regs, long error_code)
{
do_int(regs, 3, (unsigned char *) (regs->ss << 4), SP(regs));
}
void handle_vm86_fault(struct vm86_regs * regs, long error_code) void handle_vm86_fault(struct vm86_regs * regs, long error_code)
{ {
...@@ -359,6 +380,12 @@ void handle_vm86_fault(struct vm86_regs * regs, long error_code) ...@@ -359,6 +380,12 @@ void handle_vm86_fault(struct vm86_regs * regs, long error_code)
return; return;
/* sti */ /* sti */
/*
* Damn. This is incorrect: the 'sti' instruction should actually
* enable interrupts after the /next/ instruction. Not good.
*
* Probably needs some horsing around with the TF flag. Aiee..
*/
case 0xfb: case 0xfb:
IP(regs)++; IP(regs)++;
set_IF(regs); set_IF(regs);
......
...@@ -307,8 +307,8 @@ int unmap_page_range(unsigned long from, unsigned long size) ...@@ -307,8 +307,8 @@ int unmap_page_range(unsigned long from, unsigned long size)
*page_table = 0; *page_table = 0;
if (1 & page) { if (1 & page) {
if (!(mem_map[MAP_NR(page)] & MAP_PAGE_RESERVED)) if (!(mem_map[MAP_NR(page)] & MAP_PAGE_RESERVED))
if (current->rss > 0) if (current->mm->rss > 0)
--current->rss; --current->mm->rss;
free_page(PAGE_MASK & page); free_page(PAGE_MASK & page);
} else } else
swap_free(page); swap_free(page);
...@@ -367,8 +367,8 @@ int zeromap_page_range(unsigned long from, unsigned long size, int mask) ...@@ -367,8 +367,8 @@ int zeromap_page_range(unsigned long from, unsigned long size, int mask)
*page_table = 0; *page_table = 0;
if (page & PAGE_PRESENT) { if (page & PAGE_PRESENT) {
if (!(mem_map[MAP_NR(page)] & MAP_PAGE_RESERVED)) if (!(mem_map[MAP_NR(page)] & MAP_PAGE_RESERVED))
if (current->rss > 0) if (current->mm->rss > 0)
--current->rss; --current->mm->rss;
free_page(PAGE_MASK & page); free_page(PAGE_MASK & page);
} else } else
swap_free(page); swap_free(page);
...@@ -429,8 +429,8 @@ int remap_page_range(unsigned long from, unsigned long to, unsigned long size, i ...@@ -429,8 +429,8 @@ int remap_page_range(unsigned long from, unsigned long to, unsigned long size, i
*page_table = 0; *page_table = 0;
if (PAGE_PRESENT & page) { if (PAGE_PRESENT & page) {
if (!(mem_map[MAP_NR(page)] & MAP_PAGE_RESERVED)) if (!(mem_map[MAP_NR(page)] & MAP_PAGE_RESERVED))
if (current->rss > 0) if (current->mm->rss > 0)
--current->rss; --current->mm->rss;
free_page(PAGE_MASK & page); free_page(PAGE_MASK & page);
} else } else
swap_free(page); swap_free(page);
...@@ -451,7 +451,7 @@ int remap_page_range(unsigned long from, unsigned long to, unsigned long size, i ...@@ -451,7 +451,7 @@ int remap_page_range(unsigned long from, unsigned long to, unsigned long size, i
else { else {
*page_table++ = (to | mask); *page_table++ = (to | mask);
if (!(mem_map[MAP_NR(to)] & MAP_PAGE_RESERVED)) { if (!(mem_map[MAP_NR(to)] & MAP_PAGE_RESERVED)) {
++current->rss; ++current->mm->rss;
mem_map[MAP_NR(to)]++; mem_map[MAP_NR(to)]++;
} }
} }
...@@ -572,13 +572,13 @@ static void __do_wp_page(unsigned long error_code, unsigned long address, ...@@ -572,13 +572,13 @@ static void __do_wp_page(unsigned long error_code, unsigned long address,
goto bad_wp_page; goto bad_wp_page;
if (old_page & PAGE_RW) if (old_page & PAGE_RW)
goto end_wp_page; goto end_wp_page;
tsk->min_flt++; tsk->mm->min_flt++;
prot = (old_page & ~PAGE_MASK) | PAGE_RW; prot = (old_page & ~PAGE_MASK) | PAGE_RW;
old_page &= PAGE_MASK; old_page &= PAGE_MASK;
if (mem_map[MAP_NR(old_page)] != 1) { if (mem_map[MAP_NR(old_page)] != 1) {
if (new_page) { if (new_page) {
if (mem_map[MAP_NR(old_page)] & MAP_PAGE_RESERVED) if (mem_map[MAP_NR(old_page)] & MAP_PAGE_RESERVED)
++tsk->rss; ++tsk->mm->rss;
copy_page(old_page,new_page); copy_page(old_page,new_page);
*(unsigned long *) pte = new_page | prot; *(unsigned long *) pte = new_page | prot;
free_page(old_page); free_page(old_page);
...@@ -770,7 +770,7 @@ int share_page(struct vm_area_struct * area, struct task_struct * tsk, ...@@ -770,7 +770,7 @@ int share_page(struct vm_area_struct * area, struct task_struct * tsk,
we can share pages with */ we can share pages with */
if(area){ if(area){
struct vm_area_struct * mpnt; struct vm_area_struct * mpnt;
for (mpnt = (*p)->mmap; mpnt; mpnt = mpnt->vm_next) { for (mpnt = (*p)->mm->mmap; mpnt; mpnt = mpnt->vm_next) {
if (mpnt->vm_ops == area->vm_ops && if (mpnt->vm_ops == area->vm_ops &&
mpnt->vm_inode->i_ino == area->vm_inode->i_ino&& mpnt->vm_inode->i_ino == area->vm_inode->i_ino&&
mpnt->vm_inode->i_dev == area->vm_inode->i_dev){ mpnt->vm_inode->i_dev == area->vm_inode->i_dev){
...@@ -836,15 +836,15 @@ void do_no_page(unsigned long error_code, unsigned long address, ...@@ -836,15 +836,15 @@ void do_no_page(unsigned long error_code, unsigned long address,
tmp = *(unsigned long *) page; tmp = *(unsigned long *) page;
if (tmp & PAGE_PRESENT) if (tmp & PAGE_PRESENT)
return; return;
++tsk->rss; ++tsk->mm->rss;
if (tmp) { if (tmp) {
++tsk->maj_flt; ++tsk->mm->maj_flt;
swap_in((unsigned long *) page); swap_in((unsigned long *) page);
return; return;
} }
address &= 0xfffff000; address &= 0xfffff000;
tmp = 0; tmp = 0;
for (mpnt = tsk->mmap; mpnt != NULL; mpnt = mpnt->vm_next) { for (mpnt = tsk->mm->mmap; mpnt != NULL; mpnt = mpnt->vm_next) {
if (address < mpnt->vm_start) if (address < mpnt->vm_start)
break; break;
if (address >= mpnt->vm_end) { if (address >= mpnt->vm_end) {
...@@ -852,7 +852,7 @@ void do_no_page(unsigned long error_code, unsigned long address, ...@@ -852,7 +852,7 @@ void do_no_page(unsigned long error_code, unsigned long address,
continue; continue;
} }
if (!mpnt->vm_ops || !mpnt->vm_ops->nopage) { if (!mpnt->vm_ops || !mpnt->vm_ops->nopage) {
++tsk->min_flt; ++tsk->mm->min_flt;
get_empty_page(tsk,address); get_empty_page(tsk,address);
return; return;
} }
...@@ -861,9 +861,9 @@ void do_no_page(unsigned long error_code, unsigned long address, ...@@ -861,9 +861,9 @@ void do_no_page(unsigned long error_code, unsigned long address,
} }
if (tsk != current) if (tsk != current)
goto ok_no_page; goto ok_no_page;
if (address >= tsk->end_data && address < tsk->brk) if (address >= tsk->mm->end_data && address < tsk->mm->brk)
goto ok_no_page; goto ok_no_page;
if (mpnt && mpnt == tsk->stk_vma && if (mpnt && mpnt == tsk->mm->stk_vma &&
address - tmp > mpnt->vm_start - address && address - tmp > mpnt->vm_start - address &&
tsk->rlim[RLIMIT_STACK].rlim_cur > mpnt->vm_end - address) { tsk->rlim[RLIMIT_STACK].rlim_cur > mpnt->vm_end - address) {
mpnt->vm_start = address; mpnt->vm_start = address;
...@@ -876,7 +876,7 @@ void do_no_page(unsigned long error_code, unsigned long address, ...@@ -876,7 +876,7 @@ void do_no_page(unsigned long error_code, unsigned long address,
if (error_code & 4) /* user level access? */ if (error_code & 4) /* user level access? */
return; return;
ok_no_page: ok_no_page:
++tsk->min_flt; ++tsk->mm->min_flt;
get_empty_page(tsk,address); get_empty_page(tsk,address);
} }
...@@ -1166,11 +1166,11 @@ void file_mmap_nopage(int error_code, struct vm_area_struct * area, unsigned lon ...@@ -1166,11 +1166,11 @@ void file_mmap_nopage(int error_code, struct vm_area_struct * area, unsigned lon
page = get_free_page(GFP_KERNEL); page = get_free_page(GFP_KERNEL);
if (share_page(area, area->vm_task, inode, address, error_code, page)) { if (share_page(area, area->vm_task, inode, address, error_code, page)) {
++area->vm_task->min_flt; ++area->vm_task->mm->min_flt;
return; return;
} }
++area->vm_task->maj_flt; ++area->vm_task->mm->maj_flt;
if (!page) { if (!page) {
oom(current); oom(current);
put_page(area->vm_task, BAD_PAGE, address, PAGE_PRIVATE); put_page(area->vm_task, BAD_PAGE, address, PAGE_PRIVATE);
......
...@@ -86,7 +86,7 @@ int do_mmap(struct file * file, unsigned long addr, unsigned long len, ...@@ -86,7 +86,7 @@ int do_mmap(struct file * file, unsigned long addr, unsigned long len,
/* Maybe this works.. Ugly it is. */ /* Maybe this works.. Ugly it is. */
addr = SHM_RANGE_START; addr = SHM_RANGE_START;
while (addr+len < SHM_RANGE_END) { while (addr+len < SHM_RANGE_END) {
for (vmm = current->mmap ; vmm ; vmm = vmm->vm_next) { for (vmm = current->mm->mmap ; vmm ; vmm = vmm->vm_next) {
if (addr >= vmm->vm_end) if (addr >= vmm->vm_end)
continue; continue;
if (addr + len <= vmm->vm_start) if (addr + len <= vmm->vm_start)
...@@ -146,7 +146,7 @@ asmlinkage int sys_mmap(unsigned long *buffer) ...@@ -146,7 +146,7 @@ asmlinkage int sys_mmap(unsigned long *buffer)
flags = get_fs_long(buffer+3); flags = get_fs_long(buffer+3);
if (!(flags & MAP_ANONYMOUS)) { if (!(flags & MAP_ANONYMOUS)) {
unsigned long fd = get_fs_long(buffer+4); unsigned long fd = get_fs_long(buffer+4);
if (fd >= NR_OPEN || !(file = current->filp[fd])) if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF; return -EBADF;
} }
return do_mmap(file, get_fs_long(buffer), get_fs_long(buffer+1), return do_mmap(file, get_fs_long(buffer), get_fs_long(buffer+1),
...@@ -259,7 +259,7 @@ int do_munmap(unsigned long addr, size_t len) ...@@ -259,7 +259,7 @@ int do_munmap(unsigned long addr, size_t len)
* every area affected in some way (by any overlap) is put * every area affected in some way (by any overlap) is put
* on the list. If nothing is put on, nothing is affected. * on the list. If nothing is put on, nothing is affected.
*/ */
npp = &current->mmap; npp = &current->mm->mmap;
free = NULL; free = NULL;
for (mpnt = *npp; mpnt != NULL; mpnt = *npp) { for (mpnt = *npp; mpnt != NULL; mpnt = *npp) {
unsigned long end = addr+len; unsigned long end = addr+len;
...@@ -346,7 +346,7 @@ int generic_mmap(struct inode * inode, struct file * file, ...@@ -346,7 +346,7 @@ int generic_mmap(struct inode * inode, struct file * file,
mpnt->vm_offset = off; mpnt->vm_offset = off;
mpnt->vm_ops = &file_mmap; mpnt->vm_ops = &file_mmap;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
merge_segments(current->mmap, NULL, NULL); merge_segments(current->mm->mmap, NULL, NULL);
return 0; return 0;
} }
...@@ -361,9 +361,9 @@ void insert_vm_struct(struct task_struct *t, struct vm_area_struct *vmp) ...@@ -361,9 +361,9 @@ void insert_vm_struct(struct task_struct *t, struct vm_area_struct *vmp)
{ {
struct vm_area_struct **nxtpp, *mpnt; struct vm_area_struct **nxtpp, *mpnt;
nxtpp = &t->mmap; nxtpp = &t->mm->mmap;
for(mpnt = t->mmap; mpnt != NULL; mpnt = mpnt->vm_next) for(mpnt = t->mm->mmap; mpnt != NULL; mpnt = mpnt->vm_next)
{ {
if (mpnt->vm_start > vmp->vm_start) if (mpnt->vm_start > vmp->vm_start)
break; break;
...@@ -464,7 +464,7 @@ static int anon_map(struct inode *ino, struct file * file, ...@@ -464,7 +464,7 @@ static int anon_map(struct inode *ino, struct file * file,
mpnt->vm_offset = 0; mpnt->vm_offset = 0;
mpnt->vm_ops = NULL; mpnt->vm_ops = NULL;
insert_vm_struct(current, mpnt); insert_vm_struct(current, mpnt);
merge_segments(current->mmap, ignoff_mergep, NULL); merge_segments(current->mm->mmap, ignoff_mergep, NULL);
return 0; return 0;
} }
......
...@@ -317,7 +317,7 @@ static int swap_out(unsigned int priority) ...@@ -317,7 +317,7 @@ static int swap_out(unsigned int priority)
} }
p = task[swap_task]; p = task[swap_task];
if(p && p->swappable && p->rss) if(p && p->mm->swappable && p->mm->rss)
break; break;
swap_task++; swap_task++;
...@@ -326,23 +326,23 @@ static int swap_out(unsigned int priority) ...@@ -326,23 +326,23 @@ static int swap_out(unsigned int priority)
/* /*
* Determine the number of pages to swap from this process. * Determine the number of pages to swap from this process.
*/ */
if(! p -> swap_cnt) { if(! p->mm->swap_cnt) {
p->dec_flt = (p->dec_flt * 3) / 4 + p->maj_flt - p->old_maj_flt; p->mm->dec_flt = (p->mm->dec_flt * 3) / 4 + p->mm->maj_flt - p->mm->old_maj_flt;
p->old_maj_flt = p->maj_flt; p->mm->old_maj_flt = p->mm->maj_flt;
if(p->dec_flt >= SWAP_RATIO / SWAP_MIN) { if(p->mm->dec_flt >= SWAP_RATIO / SWAP_MIN) {
p->dec_flt = SWAP_RATIO / SWAP_MIN; p->mm->dec_flt = SWAP_RATIO / SWAP_MIN;
p->swap_cnt = SWAP_MIN; p->mm->swap_cnt = SWAP_MIN;
} else if(p->dec_flt <= SWAP_RATIO / SWAP_MAX) } else if(p->mm->dec_flt <= SWAP_RATIO / SWAP_MAX)
p->swap_cnt = SWAP_MAX; p->mm->swap_cnt = SWAP_MAX;
else else
p->swap_cnt = SWAP_RATIO / p->dec_flt; p->mm->swap_cnt = SWAP_RATIO / p->mm->dec_flt;
} }
/* /*
* Go through process' page directory. * Go through process' page directory.
*/ */
for(table = p->swap_table; table < 1024; table++) { for(table = p->mm->swap_table; table < 1024; table++) {
pg_table = ((unsigned long *) p->tss.cr3)[table]; pg_table = ((unsigned long *) p->tss.cr3)[table];
if(pg_table >= high_memory) if(pg_table >= high_memory)
continue; continue;
...@@ -359,34 +359,34 @@ static int swap_out(unsigned int priority) ...@@ -359,34 +359,34 @@ static int swap_out(unsigned int priority)
/* /*
* Go through this page table. * Go through this page table.
*/ */
for(page = p->swap_page; page < 1024; page++) { for(page = p->mm->swap_page; page < 1024; page++) {
switch(try_to_swap_out(page + (unsigned long *) pg_table)) { switch(try_to_swap_out(page + (unsigned long *) pg_table)) {
case 0: case 0:
break; break;
case 1: case 1:
p->rss--; p->mm->rss--;
/* continue with the following page the next time */ /* continue with the following page the next time */
p->swap_table = table; p->mm->swap_table = table;
p->swap_page = page + 1; p->mm->swap_page = page + 1;
if((--p->swap_cnt) == 0) if((--p->mm->swap_cnt) == 0)
swap_task++; swap_task++;
return 1; return 1;
default: default:
p->rss--; p->mm->rss--;
break; break;
} }
} }
p->swap_page = 0; p->mm->swap_page = 0;
} }
/* /*
* Finish work with this process, if we reached the end of the page * Finish work with this process, if we reached the end of the page
* directory. Mark restart from the beginning the next time. * directory. Mark restart from the beginning the next time.
*/ */
p->swap_table = 0; p->mm->swap_table = 0;
} }
return 0; return 0;
} }
...@@ -419,7 +419,7 @@ static int swap_out(unsigned int priority) ...@@ -419,7 +419,7 @@ static int swap_out(unsigned int priority)
goto check_task; goto check_task;
} }
p = task[swap_task]; p = task[swap_task];
if (!p || !p->swappable) { if (!p || !p->mm->swappable) {
swap_task++; swap_task++;
goto check_task; goto check_task;
} }
...@@ -450,8 +450,8 @@ static int swap_out(unsigned int priority) ...@@ -450,8 +450,8 @@ static int swap_out(unsigned int priority)
} }
switch (try_to_swap_out(swap_page + (unsigned long *) pg_table)) { switch (try_to_swap_out(swap_page + (unsigned long *) pg_table)) {
case 0: break; case 0: break;
case 1: p->rss--; return 1; case 1: p->mm->rss--; return 1;
default: p->rss--; default: p->mm->rss--;
} }
swap_page++; swap_page++;
goto check_table; goto check_table;
...@@ -689,7 +689,7 @@ static int try_to_unuse(unsigned int type) ...@@ -689,7 +689,7 @@ static int try_to_unuse(unsigned int type)
read_swap_page(page, (char *) tmp); read_swap_page(page, (char *) tmp);
if (*ppage == page) { if (*ppage == page) {
*ppage = tmp | (PAGE_DIRTY | PAGE_PRIVATE); *ppage = tmp | (PAGE_DIRTY | PAGE_PRIVATE);
++p->rss; ++p->mm->rss;
swap_free(page); swap_free(page);
tmp = 0; tmp = 0;
} }
......
...@@ -112,13 +112,13 @@ get_fd(struct inode *inode) ...@@ -112,13 +112,13 @@ get_fd(struct inode *inode)
file = get_empty_filp(); file = get_empty_filp();
if (!file) return(-1); if (!file) return(-1);
for (fd = 0; fd < NR_OPEN; ++fd) for (fd = 0; fd < NR_OPEN; ++fd)
if (!current->filp[fd]) break; if (!current->files->fd[fd]) break;
if (fd == NR_OPEN) { if (fd == NR_OPEN) {
file->f_count = 0; file->f_count = 0;
return(-1); return(-1);
} }
FD_CLR(fd, &current->close_on_exec); FD_CLR(fd, &current->files->close_on_exec);
current->filp[fd] = file; current->files->fd[fd] = file;
file->f_op = &socket_file_ops; file->f_op = &socket_file_ops;
file->f_mode = 3; file->f_mode = 3;
file->f_flags = 0; file->f_flags = 0;
...@@ -166,7 +166,7 @@ sockfd_lookup(int fd, struct file **pfile) ...@@ -166,7 +166,7 @@ sockfd_lookup(int fd, struct file **pfile)
{ {
struct file *file; struct file *file;
if (fd < 0 || fd >= NR_OPEN || !(file = current->filp[fd])) return(NULL); if (fd < 0 || fd >= NR_OPEN || !(file = current->files->fd[fd])) return(NULL);
if (pfile) *pfile = file; if (pfile) *pfile = file;
return(socki_lookup(file->f_inode)); return(socki_lookup(file->f_inode));
} }
...@@ -548,7 +548,7 @@ sock_bind(int fd, struct sockaddr *umyaddr, int addrlen) ...@@ -548,7 +548,7 @@ sock_bind(int fd, struct sockaddr *umyaddr, int addrlen)
int i; int i;
DPRINTF((net_debug, "NET: sock_bind: fd = %d\n", fd)); DPRINTF((net_debug, "NET: sock_bind: fd = %d\n", fd));
if (fd < 0 || fd >= NR_OPEN || current->filp[fd] == NULL) if (fd < 0 || fd >= NR_OPEN || current->files->fd[fd] == NULL)
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
if ((i = sock->ops->bind(sock, umyaddr, addrlen)) < 0) { if ((i = sock->ops->bind(sock, umyaddr, addrlen)) < 0) {
...@@ -570,7 +570,7 @@ sock_listen(int fd, int backlog) ...@@ -570,7 +570,7 @@ sock_listen(int fd, int backlog)
struct socket *sock; struct socket *sock;
DPRINTF((net_debug, "NET: sock_listen: fd = %d\n", fd)); DPRINTF((net_debug, "NET: sock_listen: fd = %d\n", fd));
if (fd < 0 || fd >= NR_OPEN || current->filp[fd] == NULL) if (fd < 0 || fd >= NR_OPEN || current->files->fd[fd] == NULL)
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
if (sock->state != SS_UNCONNECTED) { if (sock->state != SS_UNCONNECTED) {
...@@ -596,7 +596,7 @@ sock_accept(int fd, struct sockaddr *upeer_sockaddr, int *upeer_addrlen) ...@@ -596,7 +596,7 @@ sock_accept(int fd, struct sockaddr *upeer_sockaddr, int *upeer_addrlen)
int i; int i;
DPRINTF((net_debug, "NET: sock_accept: fd = %d\n", fd)); DPRINTF((net_debug, "NET: sock_accept: fd = %d\n", fd));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, &file))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, &file))) return(-ENOTSOCK);
...@@ -651,7 +651,7 @@ sock_connect(int fd, struct sockaddr *uservaddr, int addrlen) ...@@ -651,7 +651,7 @@ sock_connect(int fd, struct sockaddr *uservaddr, int addrlen)
int i; int i;
DPRINTF((net_debug, "NET: sock_connect: fd = %d\n", fd)); DPRINTF((net_debug, "NET: sock_connect: fd = %d\n", fd));
if (fd < 0 || fd >= NR_OPEN || (file=current->filp[fd]) == NULL) if (fd < 0 || fd >= NR_OPEN || (file=current->files->fd[fd]) == NULL)
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, &file))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, &file))) return(-ENOTSOCK);
...@@ -686,7 +686,7 @@ sock_getsockname(int fd, struct sockaddr *usockaddr, int *usockaddr_len) ...@@ -686,7 +686,7 @@ sock_getsockname(int fd, struct sockaddr *usockaddr, int *usockaddr_len)
struct socket *sock; struct socket *sock;
DPRINTF((net_debug, "NET: sock_getsockname: fd = %d\n", fd)); DPRINTF((net_debug, "NET: sock_getsockname: fd = %d\n", fd));
if (fd < 0 || fd >= NR_OPEN || current->filp[fd] == NULL) if (fd < 0 || fd >= NR_OPEN || current->files->fd[fd] == NULL)
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
return(sock->ops->getname(sock, usockaddr, usockaddr_len, 0)); return(sock->ops->getname(sock, usockaddr, usockaddr_len, 0));
...@@ -699,7 +699,7 @@ sock_getpeername(int fd, struct sockaddr *usockaddr, int *usockaddr_len) ...@@ -699,7 +699,7 @@ sock_getpeername(int fd, struct sockaddr *usockaddr, int *usockaddr_len)
struct socket *sock; struct socket *sock;
DPRINTF((net_debug, "NET: sock_getpeername: fd = %d\n", fd)); DPRINTF((net_debug, "NET: sock_getpeername: fd = %d\n", fd));
if (fd < 0 || fd >= NR_OPEN || current->filp[fd] == NULL) if (fd < 0 || fd >= NR_OPEN || current->files->fd[fd] == NULL)
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
return(sock->ops->getname(sock, usockaddr, usockaddr_len, 1)); return(sock->ops->getname(sock, usockaddr, usockaddr_len, 1));
...@@ -716,7 +716,7 @@ sock_send(int fd, void * buff, int len, unsigned flags) ...@@ -716,7 +716,7 @@ sock_send(int fd, void * buff, int len, unsigned flags)
"NET: sock_send(fd = %d, buff = %X, len = %d, flags = %X)\n", "NET: sock_send(fd = %d, buff = %X, len = %d, flags = %X)\n",
fd, buff, len, flags)); fd, buff, len, flags));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
...@@ -735,7 +735,7 @@ sock_sendto(int fd, void * buff, int len, unsigned flags, ...@@ -735,7 +735,7 @@ sock_sendto(int fd, void * buff, int len, unsigned flags,
"NET: sock_sendto(fd = %d, buff = %X, len = %d, flags = %X," "NET: sock_sendto(fd = %d, buff = %X, len = %d, flags = %X,"
" addr=%X, alen = %d\n", fd, buff, len, flags, addr, addr_len)); " addr=%X, alen = %d\n", fd, buff, len, flags, addr, addr_len));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
...@@ -754,7 +754,7 @@ sock_recv(int fd, void * buff, int len, unsigned flags) ...@@ -754,7 +754,7 @@ sock_recv(int fd, void * buff, int len, unsigned flags)
"NET: sock_recv(fd = %d, buff = %X, len = %d, flags = %X)\n", "NET: sock_recv(fd = %d, buff = %X, len = %d, flags = %X)\n",
fd, buff, len, flags)); fd, buff, len, flags));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
...@@ -773,7 +773,7 @@ sock_recvfrom(int fd, void * buff, int len, unsigned flags, ...@@ -773,7 +773,7 @@ sock_recvfrom(int fd, void * buff, int len, unsigned flags,
"NET: sock_recvfrom(fd = %d, buff = %X, len = %d, flags = %X," "NET: sock_recvfrom(fd = %d, buff = %X, len = %d, flags = %X,"
" addr=%X, alen=%X\n", fd, buff, len, flags, addr, addr_len)); " addr=%X, alen=%X\n", fd, buff, len, flags, addr, addr_len));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
...@@ -793,7 +793,7 @@ sock_setsockopt(int fd, int level, int optname, char *optval, int optlen) ...@@ -793,7 +793,7 @@ sock_setsockopt(int fd, int level, int optname, char *optval, int optlen)
DPRINTF((net_debug, " optval = %X, optlen = %d)\n", DPRINTF((net_debug, " optval = %X, optlen = %d)\n",
optval, optlen)); optval, optlen));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
...@@ -812,7 +812,7 @@ sock_getsockopt(int fd, int level, int optname, char *optval, int *optlen) ...@@ -812,7 +812,7 @@ sock_getsockopt(int fd, int level, int optname, char *optval, int *optlen)
DPRINTF((net_debug, " optval = %X, optlen = %X)\n", DPRINTF((net_debug, " optval = %X, optlen = %X)\n",
optval, optlen)); optval, optlen));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
...@@ -829,7 +829,7 @@ sock_shutdown(int fd, int how) ...@@ -829,7 +829,7 @@ sock_shutdown(int fd, int how)
DPRINTF((net_debug, "NET: sock_shutdown(fd = %d, how = %d)\n", fd, how)); DPRINTF((net_debug, "NET: sock_shutdown(fd = %d, how = %d)\n", fd, how));
if (fd < 0 || fd >= NR_OPEN || ((file = current->filp[fd]) == NULL)) if (fd < 0 || fd >= NR_OPEN || ((file = current->files->fd[fd]) == NULL))
return(-EBADF); return(-EBADF);
if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK); if (!(sock = sockfd_lookup(fd, NULL))) return(-ENOTSOCK);
......
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