aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Benedict Torvalds <torvalds@klaava.Helsinki.FI>1992-06-18 14:50:12 +0000
committerNicolas Pitre <nico@cam.org>2007-08-19 14:19:04 -0400
commit104ec363bda00e91a1701e18e691d39a666a0180 (patch)
treed159cdb49511ca4bb29678a4630c1a85fa061602
parent2d7bd0389f1494040efcddd5a1b651f362bbf2c9 (diff)
downloadarchive-104ec363bda00e91a1701e18e691d39a666a0180.tar.gz
32-bit inodes: patch4v0.96a-pl4
Ok, patch4 implements 32-bit inode numbers (and thus the new stat/lstat/fstat system calls), as well as correcting the bad rs-performance on some machines that showed up in patch3. It's currently only on banjo, but I'll copy it around eventually. Again, you don't miss much if you don't use this patch: it's mainly for (a) the serial problems and (b) for hlu etc that want to test out the 32-bit interface. It does some other magical tricks as well (uses less memory in the low 1M region by moving the screen and tty buffer to high memory), if anybody is interested. Linus
-rw-r--r--fs/exec.c2
-rw-r--r--fs/fcntl.c2
-rw-r--r--fs/inode.c2
-rw-r--r--fs/ioctl.c2
-rw-r--r--fs/minix/blkdev.c2
-rw-r--r--fs/minix/chrdev.c2
-rw-r--r--fs/minix/dir.c3
-rw-r--r--fs/minix/file.c2
-rw-r--r--fs/minix/inode.c3
-rw-r--r--fs/minix/namei.c4
-rw-r--r--fs/minix/symlink.c3
-rw-r--r--fs/minix/truncate.c2
-rw-r--r--fs/namei.c2
-rw-r--r--fs/open.c6
-rw-r--r--fs/pipe.c1
-rw-r--r--fs/read_write.c2
-rw-r--r--fs/select.c2
-rw-r--r--fs/stat.c78
-rw-r--r--fs/super.c2
-rw-r--r--include/fcntl.h8
-rw-r--r--include/linux/config_rel.h2
-rw-r--r--include/linux/config_ver.h2
-rw-r--r--include/linux/fs.h22
-rw-r--r--include/linux/lp.h2
-rw-r--r--include/linux/stat.h76
-rw-r--r--include/linux/sys.h7
-rw-r--r--include/linux/tty.h17
-rw-r--r--include/linux/unistd.h21
-rw-r--r--include/linux/utsname.h24
-rw-r--r--include/signal.h8
-rw-r--r--include/termios.h8
-rw-r--r--include/time.h8
-rw-r--r--include/unistd.h9
-rw-r--r--include/utime.h8
-rw-r--r--init/main.c6
-rw-r--r--kernel/chr_drv/console.c36
-rw-r--r--kernel/chr_drv/lp.c3
-rw-r--r--kernel/chr_drv/mem.c7
-rw-r--r--kernel/chr_drv/serial.c27
-rw-r--r--kernel/chr_drv/tty_io.c58
-rw-r--r--kernel/chr_drv/vt.c3
-rw-r--r--kernel/chr_drv/vt_kern.h2
-rw-r--r--kernel/ptrace.c5
-rw-r--r--kernel/sys.c35
-rw-r--r--lib/_exit.c2
-rw-r--r--lib/close.c2
-rw-r--r--lib/dup.c2
-rw-r--r--lib/execve.c2
-rw-r--r--lib/itimer.c2
-rw-r--r--lib/open.c2
-rw-r--r--lib/setsid.c3
-rw-r--r--lib/wait.c2
-rw-r--r--lib/write.c3
-rw-r--r--mm/memory.c3
-rw-r--r--mm/mmap.c2
-rw-r--r--mm/swap.c2
-rw-r--r--net/socket.c2
-rw-r--r--net/unix.c2
58 files changed, 389 insertions, 168 deletions
diff --git a/fs/exec.c b/fs/exec.c
index e8a58cb..992adc4 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -20,7 +20,7 @@
#include <signal.h>
#include <errno.h>
#include <linux/string.h>
-#include <sys/stat.h>
+#include <linux/stat.h>
#include <sys/ptrace.h>
#include <a.out.h>
#include <fcntl.h>
diff --git a/fs/fcntl.c b/fs/fcntl.c
index bf2861d..555c901 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -7,7 +7,7 @@
#include <errno.h>
#include <fcntl.h>
-#include <sys/stat.h>
+#include <linux/stat.h>
#include <asm/segment.h>
diff --git a/fs/inode.c b/fs/inode.c
index 1f144c6..24c5316 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -5,7 +5,7 @@
*/
#include <linux/string.h>
-#include <sys/stat.h>
+#include <linux/stat.h>
#include <linux/sched.h>
#include <linux/kernel.h>
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 7b28116..7aedb24 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -6,8 +6,8 @@
#include <linux/string.h>
#include <errno.h>
-#include <sys/stat.h>
+#include <linux/stat.h>
#include <linux/sched.h>
int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
diff --git a/fs/minix/blkdev.c b/fs/minix/blkdev.c
index a70b513..eec544d 100644
--- a/fs/minix/blkdev.c
+++ b/fs/minix/blkdev.c
@@ -7,10 +7,10 @@
#include <linux/sched.h>
#include <linux/minix_fs.h>
#include <linux/tty.h>
+#include <linux/stat.h>
#include <errno.h>
#include <fcntl.h>
-#include <sys/stat.h>
/*
* Called every time a minix block special file is opened
diff --git a/fs/minix/chrdev.c b/fs/minix/chrdev.c
index 8957eb4..da7e9fc 100644
--- a/fs/minix/chrdev.c
+++ b/fs/minix/chrdev.c
@@ -7,10 +7,10 @@
#include <linux/sched.h>
#include <linux/minix_fs.h>
#include <linux/tty.h>
+#include <linux/stat.h>
#include <errno.h>
#include <fcntl.h>
-#include <sys/stat.h>
/*
* Called every time a minix character special file is opened
diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index 467d227..bfa3551 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -8,12 +8,11 @@
#include <errno.h>
-#include <sys/stat.h>
-
#include <asm/segment.h>
#include <linux/fs.h>
#include <linux/minix_fs.h>
+#include <linux/stat.h>
static int minix_readdir(struct inode *, struct file *, struct dirent *, int);
diff --git a/fs/minix/file.c b/fs/minix/file.c
index 7b6e033..6c6bf75 100644
--- a/fs/minix/file.c
+++ b/fs/minix/file.c
@@ -10,7 +10,6 @@
#include <fcntl.h>
#include <sys/dirent.h>
-#include <sys/stat.h>
#include <asm/segment.h>
#include <asm/system.h>
@@ -18,6 +17,7 @@
#include <linux/sched.h>
#include <linux/minix_fs.h>
#include <linux/kernel.h>
+#include <linux/stat.h>
#define NBUF 16
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index f528743..485295e 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -5,8 +5,7 @@
*/
#include <linux/string.h>
-#include <sys/stat.h>
-
+#include <linux/stat.h>
#include <linux/sched.h>
#include <linux/minix_fs.h>
#include <linux/kernel.h>
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 8682e9c..4df81df 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -7,13 +7,13 @@
#include <linux/sched.h>
#include <linux/minix_fs.h>
#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/stat.h>
#include <asm/segment.h>
-#include <linux/string.h>
#include <fcntl.h>
#include <errno.h>
#include <const.h>
-#include <sys/stat.h>
/*
* comment out this line if you want names > MINIX_NAME_LEN chars to be
diff --git a/fs/minix/symlink.c b/fs/minix/symlink.c
index 0b5c5dc..1f99b07 100644
--- a/fs/minix/symlink.c
+++ b/fs/minix/symlink.c
@@ -8,13 +8,12 @@
#include <errno.h>
-#include <sys/stat.h>
-
#include <asm/segment.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/minix_fs.h>
+#include <linux/stat.h>
static int minix_readlink(struct inode *, char *, int);
static struct inode * minix_follow_link(struct inode *, struct inode *);
diff --git a/fs/minix/truncate.c b/fs/minix/truncate.c
index 215daf3..9b35e05 100644
--- a/fs/minix/truncate.c
+++ b/fs/minix/truncate.c
@@ -7,10 +7,10 @@
#include <linux/sched.h>
#include <linux/minix_fs.h>
#include <linux/tty.h>
+#include <linux/stat.h>
#include <errno.h>
#include <fcntl.h>
-#include <sys/stat.h>
/*
* Truncate has the most races in the whole filesystem: coding it is
diff --git a/fs/namei.c b/fs/namei.c
index eccb04c..ef5131a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -16,7 +16,7 @@
#include <fcntl.h>
#include <errno.h>
#include <const.h>
-#include <sys/stat.h>
+#include <linux/stat.h>
struct inode * _namei(const char * filename, struct inode * base,
int follow_links);
diff --git a/fs/open.c b/fs/open.c
index 33e3957..8aef2fb 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -9,9 +9,9 @@
#include <sys/types.h>
#include <utime.h>
-#include <sys/stat.h>
#include <sys/vfs.h>
+#include <linux/stat.h>
#include <linux/string.h>
#include <linux/sched.h>
#include <linux/kernel.h>
@@ -141,8 +141,8 @@ int sys_access(const char * filename,int mode)
iput(inode);
if (current->uid == inode->i_uid)
res >>= 6;
- else if (current->gid == inode->i_gid)
- res >>= 6;
+ else if (in_group_p(inode->i_gid))
+ res >>= 3;
if ((res & 0007 & mode) == mode)
return 0;
/*
diff --git a/fs/pipe.c b/fs/pipe.c
index a3f48cd..c508957 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -150,6 +150,7 @@ int sys_pipe(unsigned long * fildes)
int fd[2];
int i,j;
+ verify_area(fildes,8);
j=0;
for(i=0;j<2 && i<NR_FILE;i++)
if (!file_table[i].f_count)
diff --git a/fs/read_write.c b/fs/read_write.c
index b28d7e7..91d4bfa 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -6,9 +6,9 @@
#include <errno.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/dirent.h>
+#include <linux/stat.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/minix_fs.h>
diff --git a/fs/select.c b/fs/select.c
index efd6549..de2d1a3 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -10,11 +10,11 @@
#include <linux/tty.h>
#include <linux/sched.h>
#include <linux/string.h>
+#include <linux/stat.h>
#include <asm/segment.h>
#include <asm/system.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
diff --git a/fs/stat.c b/fs/stat.c
index 029ec2f..a169de5 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -5,19 +5,20 @@
*/
#include <errno.h>
-#include <sys/stat.h>
+#include <linux/stat.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <asm/segment.h>
-static void cp_stat(struct inode * inode, struct stat * statbuf)
+static void cp_old_stat(struct inode * inode, struct old_stat * statbuf)
{
- struct stat tmp;
- int i;
+ struct old_stat tmp;
- verify_area(statbuf,sizeof (struct stat));
+ if (inode->i_ino & 0xffff0000)
+ printk("Warning: using old stat() call on bigfs\n");
+ verify_area(statbuf,sizeof (*statbuf));
tmp.st_dev = inode->i_dev;
tmp.st_ino = inode->i_ino;
tmp.st_mode = inode->i_mode;
@@ -29,40 +30,91 @@ static void cp_stat(struct inode * inode, struct stat * statbuf)
tmp.st_atime = inode->i_atime;
tmp.st_mtime = inode->i_mtime;
tmp.st_ctime = inode->i_ctime;
- for (i=0 ; i<sizeof (tmp) ; i++)
- put_fs_byte(((char *) &tmp)[i],i + (char *) statbuf);
+ memcpy_tofs(statbuf,&tmp,sizeof(tmp));
}
-int sys_stat(char * filename, struct stat * statbuf)
+static void cp_new_stat(struct inode * inode, struct new_stat * statbuf)
+{
+ struct new_stat tmp = {0, };
+
+ verify_area(statbuf,sizeof (*statbuf));
+ tmp.st_dev = inode->i_dev;
+ tmp.st_ino = inode->i_ino;
+ tmp.st_mode = inode->i_mode;
+ tmp.st_nlink = inode->i_nlink;
+ tmp.st_uid = inode->i_uid;
+ tmp.st_gid = inode->i_gid;
+ tmp.st_rdev = inode->i_rdev;
+ tmp.st_size = inode->i_size;
+ tmp.st_atime = inode->i_atime;
+ tmp.st_mtime = inode->i_mtime;
+ tmp.st_ctime = inode->i_ctime;
+ memcpy_tofs(statbuf,&tmp,sizeof(tmp));
+}
+
+int sys_stat(char * filename, struct old_stat * statbuf)
+{
+ struct inode * inode;
+
+ if (!(inode=namei(filename)))
+ return -ENOENT;
+ cp_old_stat(inode,statbuf);
+ iput(inode);
+ return 0;
+}
+
+int sys_newstat(char * filename, struct new_stat * statbuf)
{
struct inode * inode;
if (!(inode=namei(filename)))
return -ENOENT;
- cp_stat(inode,statbuf);
+ cp_new_stat(inode,statbuf);
iput(inode);
return 0;
}
-int sys_lstat(char * filename, struct stat * statbuf)
+int sys_lstat(char * filename, struct old_stat * statbuf)
{
struct inode * inode;
if (!(inode = lnamei(filename)))
return -ENOENT;
- cp_stat(inode,statbuf);
+ cp_old_stat(inode,statbuf);
iput(inode);
return 0;
}
-int sys_fstat(unsigned int fd, struct stat * statbuf)
+int sys_newlstat(char * filename, struct new_stat * statbuf)
+{
+ struct inode * inode;
+
+ if (!(inode = lnamei(filename)))
+ return -ENOENT;
+ cp_new_stat(inode,statbuf);
+ iput(inode);
+ return 0;
+}
+
+int sys_fstat(unsigned int fd, struct old_stat * statbuf)
+{
+ struct file * f;
+ struct inode * inode;
+
+ if (fd >= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
+ return -EBADF;
+ cp_old_stat(inode,statbuf);
+ return 0;
+}
+
+int sys_newfstat(unsigned int fd, struct new_stat * statbuf)
{
struct file * f;
struct inode * inode;
if (fd >= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
return -EBADF;
- cp_stat(inode,statbuf);
+ cp_new_stat(inode,statbuf);
return 0;
}
diff --git a/fs/super.c b/fs/super.c
index 78f8b6c..a3b6802 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -11,11 +11,11 @@
#include <linux/sched.h>
#include <linux/minix_fs.h>
#include <linux/kernel.h>
+#include <linux/stat.h>
#include <asm/system.h>
#include <asm/segment.h>
#include <errno.h>
-#include <sys/stat.h>
int sync_dev(int dev);
void wait_for_keypress(void);
diff --git a/include/fcntl.h b/include/fcntl.h
index 4bc0c10..6d4bc22 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -48,8 +48,16 @@ struct flock {
pid_t l_pid;
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern int creat(const char * filename,mode_t mode);
extern int fcntl(int fildes,int cmd, ...);
extern int open(const char * filename, int flags, ...);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/linux/config_rel.h b/include/linux/config_rel.h
index e199879..21d9dd8 100644
--- a/include/linux/config_rel.h
+++ b/include/linux/config_rel.h
@@ -1 +1 @@
-#define UTS_RELEASE "0.96a-10"
+#define UTS_RELEASE "0.96a-35"
diff --git a/include/linux/config_ver.h b/include/linux/config_ver.h
index dde55d7..e80b945 100644
--- a/include/linux/config_ver.h
+++ b/include/linux/config_ver.h
@@ -1 +1 @@
-#define UTS_VERSION "05/22/92"
+#define UTS_VERSION "06/17/92"
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 329f8ac..639f458 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -88,17 +88,17 @@ struct buffer_head {
};
struct inode {
- dev_t i_dev;
- ino_t i_ino;
- umode_t i_mode;
- nlink_t i_nlink;
- uid_t i_uid;
- gid_t i_gid;
- dev_t i_rdev;
- off_t i_size;
- time_t i_atime;
- time_t i_mtime;
- time_t i_ctime;
+ dev_t i_dev;
+ unsigned long i_ino;
+ umode_t i_mode;
+ nlink_t i_nlink;
+ uid_t i_uid;
+ gid_t i_gid;
+ dev_t i_rdev;
+ off_t i_size;
+ time_t i_atime;
+ time_t i_mtime;
+ time_t i_ctime;
unsigned long i_data[16];
struct inode_operations * i_op;
struct super_block * i_sb;
diff --git a/include/linux/lp.h b/include/linux/lp.h
index dd92cf0..785b17d 100644
--- a/include/linux/lp.h
+++ b/include/linux/lp.h
@@ -100,4 +100,4 @@ struct lp_struct lp_table[] = {
* function prototypes
*/
-extern void lp_init(void);
+extern long lp_init(long);
diff --git a/include/linux/stat.h b/include/linux/stat.h
new file mode 100644
index 0000000..2e11b1c
--- /dev/null
+++ b/include/linux/stat.h
@@ -0,0 +1,76 @@
+#ifndef _LINUX_STAT_H
+#define _LINUX_STAT_H
+
+struct old_stat {
+ unsigned short st_dev;
+ unsigned short st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+ unsigned long st_size;
+ unsigned long st_atime;
+ unsigned long st_mtime;
+ unsigned long st_ctime;
+};
+
+struct new_stat {
+ unsigned short st_dev;
+ unsigned short __pad1;
+ unsigned long st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+ unsigned short __pad2;
+ unsigned long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ unsigned long st_atime;
+ unsigned long __unused1;
+ unsigned long st_mtime;
+ unsigned long __unused2;
+ unsigned long st_ctime;
+ unsigned long __unused3;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+#define S_IFMT 00170000
+#define S_IFSOCK 0140000
+#define S_IFLNK 0120000
+#define S_IFREG 0100000
+#define S_IFBLK 0060000
+#define S_IFDIR 0040000
+#define S_IFCHR 0020000
+#define S_IFIFO 0010000
+#define S_ISUID 0004000
+#define S_ISGID 0002000
+#define S_ISVTX 0001000
+
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+
+#define S_IRWXU 00700
+#define S_IRUSR 00400
+#define S_IWUSR 00200
+#define S_IXUSR 00100
+
+#define S_IRWXG 00070
+#define S_IRGRP 00040
+#define S_IWGRP 00020
+#define S_IXGRP 00010
+
+#define S_IRWXO 00007
+#define S_IROTH 00004
+#define S_IWOTH 00002
+#define S_IXOTH 00001
+
+#endif
diff --git a/include/linux/sys.h b/include/linux/sys.h
index 79640f1..b3c2e33 100644
--- a/include/linux/sys.h
+++ b/include/linux/sys.h
@@ -108,6 +108,10 @@ extern int sys_socketcall();
extern int sys_syslog();
extern int sys_getitimer();
extern int sys_setitimer();
+extern int sys_newstat();
+extern int sys_newlstat();
+extern int sys_newfstat();
+extern int sys_newuname();
fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
@@ -128,7 +132,8 @@ sys_select, sys_symlink, sys_lstat, sys_readlink, sys_uselib,
sys_swapon, sys_reboot, sys_readdir, sys_mmap, sys_munmap,
sys_truncate, sys_ftruncate, sys_fchmod, sys_fchown, sys_getpriority,
sys_setpriority, sys_profil, sys_statfs, sys_fstatfs, sys_ioperm,
-sys_socketcall, sys_syslog, sys_setitimer, sys_getitimer };
+sys_socketcall, sys_syslog, sys_setitimer, sys_getitimer, sys_newstat,
+sys_newlstat, sys_newfstat, sys_newuname };
/* So we don't have to do any more manual updating.... */
int NR_syscalls = sizeof(sys_call_table)/sizeof(fn_ptr);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 82dd517..91c08d6 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -11,11 +11,16 @@
#include <asm/system.h>
-#define MAX_CONSOLES 8
+#define NR_CONSOLES 8
#define NR_SERIALS 4
#define NR_PTYS 4
-extern int NR_CONSOLES;
+/*
+ * This character is the same as _POSIX_VDISABLE: it cannot be used as
+ * a c_cc[] character, but indicates that a particular special character
+ * isn't in use (eg VINTR ahs no character etc)
+ */
+#define __DISABLED_CHAR '\0'
#include <termios.h>
@@ -173,10 +178,10 @@ extern unsigned long video_num_lines;
*/
#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
-extern void rs_init(void);
-extern void lp_init(void);
-extern void con_init(void);
-extern void tty_init(void);
+extern long rs_init(long);
+extern long lp_init(long);
+extern long con_init(long);
+extern long tty_init(long);
extern void flush(struct tty_queue * queue);
diff --git a/include/linux/unistd.h b/include/linux/unistd.h
index a9e8501..d741dfc 100644
--- a/include/linux/unistd.h
+++ b/include/linux/unistd.h
@@ -24,7 +24,7 @@
#define __NR_chmod 15
#define __NR_chown 16
#define __NR_break 17
-#define __NR_stat 18
+#define __NR_oldstat 18
#define __NR_lseek 19
#define __NR_getpid 20
#define __NR_mount 21
@@ -34,7 +34,7 @@
#define __NR_stime 25
#define __NR_ptrace 26
#define __NR_alarm 27
-#define __NR_fstat 28
+#define __NR_oldfstat 28
#define __NR_pause 29
#define __NR_utime 30
#define __NR_stty 31
@@ -65,7 +65,7 @@
#define __NR_mpx 56
#define __NR_setpgid 57
#define __NR_ulimit 58
-#define __NR_uname 59
+#define __NR_olduname 59
#define __NR_umask 60
#define __NR_chroot 61
#define __NR_ustat 62
@@ -90,7 +90,7 @@
#define __NR_setgroups 81
#define __NR_select 82
#define __NR_symlink 83
-#define __NR_lstat 84
+#define __NR_oldlstat 84
#define __NR_readlink 85
#define __NR_uselib 86
#define __NR_swapon 87
@@ -102,10 +102,6 @@
#define __NR_ftruncate 93
#define __NR_fchmod 94
#define __NR_fchown 95
-/*
- * Not all of these are implemented yet, but these are the
- * numbers they will use.
- */
#define __NR_getpriority 96
#define __NR_setpriority 97
#define __NR_profil 98
@@ -114,11 +110,14 @@
#define __NR_ioperm 101
#define __NR_socketcall 102
#define __NR_syslog 103
-
-extern int errno;
-
#define __NR_setitimer 104
#define __NR_getitimer 105
+#define __NR_stat 106
+#define __NR_lstat 107
+#define __NR_fstat 108
+#define __NR_uname 109
+
+extern int errno;
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
#define _syscall0(type,name) \
diff --git a/include/linux/utsname.h b/include/linux/utsname.h
new file mode 100644
index 0000000..4efd512
--- /dev/null
+++ b/include/linux/utsname.h
@@ -0,0 +1,24 @@
+#ifndef _LINUX_UTSNAME_H
+#define _LINUX_UTSNAME_H
+
+#define __OLD_UTS_LEN 8
+
+struct old_utsname {
+ char sysname[9];
+ char nodename[9];
+ char release[9];
+ char version[9];
+ char machine[9];
+};
+
+#define __NEW_UTS_LEN 64
+
+struct new_utsname {
+ char sysname[65];
+ char nodename[65];
+ char release[65];
+ char version[65];
+ char machine[65];
+};
+
+#endif
diff --git a/include/signal.h b/include/signal.h
index 91df52e..00ef568 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -80,6 +80,10 @@ struct sigaction {
void (*sa_restorer)(void);
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void (*signal(int _sig, void (*_func)(int)))(int);
int raise(int sig);
int kill(pid_t pid, int sig);
@@ -93,4 +97,8 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset);
int sigsuspend(sigset_t *sigmask);
int sigaction(int sig, struct sigaction *act, struct sigaction *oldact);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _SIGNAL_H */
diff --git a/include/termios.h b/include/termios.h
index 740f3d8..42410af 100644
--- a/include/termios.h
+++ b/include/termios.h
@@ -211,6 +211,10 @@ struct termios {
#define TCSADRAIN 1
#define TCSAFLUSH 2
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern speed_t cfgetispeed(struct termios *termios_p);
extern speed_t cfgetospeed(struct termios *termios_p);
extern int cfsetispeed(struct termios *termios_p, speed_t speed);
@@ -223,4 +227,8 @@ extern int tcsendbreak(int fildes, int duration);
extern int tcsetattr(int fildes, int optional_actions,
struct termios *termios_p);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/time.h b/include/time.h
index f7e7ba1..fa096d9 100644
--- a/include/time.h
+++ b/include/time.h
@@ -34,6 +34,10 @@ struct tm {
#define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
+#ifdef __cplusplus
+extern "C" {
+#endif
+
clock_t clock(void);
time_t time(time_t * tp);
double difftime(time_t time2, time_t time1);
@@ -46,4 +50,8 @@ struct tm *localtime(const time_t * tp);
size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp);
void tzset(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/unistd.h b/include/unistd.h
index e7a1c6e..041977b 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -70,6 +70,10 @@
/* XXX - illegal. */
extern int errno;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* XXX - several non-POSIX functions here, and POSIX functions that are
* supposed to be declared elsewhere. Non-promotion of short types in
* prototypes may cause trouble. Arg names should be prefixed by
@@ -152,4 +156,9 @@ int setgroups(int gidsetlen, gid_t *gidset);
int select(int width, fd_set * readfds, fd_set * writefds,
fd_set * exceptfds, struct timeval * timeout);
int swapon(const char * specialfile);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/utime.h b/include/utime.h
index 83f07c7..a7b79b3 100644
--- a/include/utime.h
+++ b/include/utime.h
@@ -8,6 +8,14 @@ struct utimbuf {
time_t modtime;
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern int utime(const char *filename, struct utimbuf *times);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/init/main.c b/init/main.c
index 839161a..80bbe0f 100644
--- a/init/main.c
+++ b/init/main.c
@@ -53,7 +53,7 @@ static char printbuf[1024];
extern int vsprintf();
extern void init(void);
extern void blk_dev_init(void);
-extern void chr_dev_init(void);
+extern long chr_dev_init(long);
extern void hd_init(void);
extern void floppy_init(void);
extern void sock_init(void);
@@ -165,11 +165,11 @@ void start_kernel(void)
#ifdef RAMDISK
main_memory_start += rd_init(main_memory_start, RAMDISK*1024);
#endif
- mem_init(main_memory_start,memory_end);
trap_init();
sched_init();
- chr_dev_init();
+ main_memory_start = chr_dev_init(main_memory_start);
blk_dev_init();
+ mem_init(main_memory_start,memory_end);
time_init();
printk("Linux version " UTS_RELEASE " " __DATE__ " " __TIME__ "\n");
buffer_init(buffer_memory_end);
diff --git a/kernel/chr_drv/console.c b/kernel/chr_drv/console.c
index 746692c..9092aae 100644
--- a/kernel/chr_drv/console.c
+++ b/kernel/chr_drv/console.c
@@ -8,7 +8,7 @@
* console.c
*
* This module implements the console io functions
- * 'void con_init(void)'
+ * 'long con_init(long)'
* 'void con_write(struct tty_queue * queue)'
* Hopefully this will be a rather complete VT102 implementation.
*
@@ -77,8 +77,6 @@
#define NPAR 16
-int NR_CONSOLES = 0;
-
extern void vt_init(void);
extern void keyboard_interrupt(void);
extern void set_leds(void);
@@ -124,12 +122,12 @@ static struct {
unsigned char vc_kbdmode;
char * vc_translate;
/* additional information is in vt_kern.h */
-} vc_cons [MAX_CONSOLES];
+} vc_cons [NR_CONSOLES];
#define MEM_BUFFER_SIZE (2*80*50*8)
-unsigned short *vc_scrbuf[MAX_CONSOLES];
-unsigned short vc_scrmembuf[MEM_BUFFER_SIZE/2];
+unsigned short *vc_scrbuf[NR_CONSOLES];
+static unsigned short * vc_scrmembuf;
static int console_blanked = 0;
#define origin (vc_cons[currcons].vc_origin)
@@ -577,7 +575,7 @@ void con_write(struct tty_struct * tty)
wake_up(&tty->write_q->proc_list);
currcons = tty - tty_table;
- if (currcons >= MAX_CONSOLES) {
+ if (currcons >= NR_CONSOLES) {
printk("con_write: illegal tty\n\r");
return;
}
@@ -867,7 +865,7 @@ return s;
}
/*
- * void con_init(void);
+ * long con_init(long);
*
* This routine initalizes console interrupts, and does nothing
* else. If you want the screen to clear, call tty_write with
@@ -876,7 +874,7 @@ return s;
* Reads the information preserved by setup.s to determine the current display
* type and sets everything accordingly.
*/
-void con_init(void)
+long con_init(long kmem_start)
{
register unsigned char a;
char *display_desc = "????";
@@ -886,11 +884,14 @@ void con_init(void)
int orig_x = ORIG_X;
int orig_y = ORIG_Y;
+ vc_scrmembuf = (unsigned short *) kmem_start;
video_num_columns = ORIG_VIDEO_COLS;
video_size_row = video_num_columns * 2;
video_num_lines = ORIG_VIDEO_LINES;
video_page = ORIG_VIDEO_PAGE;
video_erase_char = 0x0720;
+ screen_size = (video_num_lines * video_size_row);
+ kmem_start += NR_CONSOLES * screen_size;
timer_table[BLANK_TIMER].fn = blank_screen;
timer_table[BLANK_TIMER].expires = 0;
if (blankinterval) {
@@ -947,13 +948,7 @@ void con_init(void)
memsetw(vc_scrmembuf,video_erase_char,MEM_BUFFER_SIZE/2);
base = (long)vc_scrmembuf;
- screen_size = (video_num_lines * video_size_row);
- NR_CONSOLES = MEM_BUFFER_SIZE / screen_size;
- if (NR_CONSOLES > MAX_CONSOLES)
- NR_CONSOLES = MAX_CONSOLES;
- if (!NR_CONSOLES)
- NR_CONSOLES = 1;
-
+
/* Initialize the variables used for scrolling (mostly EGA/VGA) */
base = origin = video_mem_start = (long)vc_scrmembuf;
@@ -978,14 +973,14 @@ void con_init(void)
vc_cons[0].vc_bold_attr = -1;
gotoxy(currcons,orig_x,orig_y);
- for (currcons = 1; currcons<NR_CONSOLES; currcons++) {
+ for (currcons = 1 ; currcons < NR_CONSOLES ; currcons++) {
vc_cons[currcons] = vc_cons[0];
vt_cons[currcons] = vt_cons[0];
base += screen_size;
- origin = video_mem_start = base;
+ x = y = 0;
+ pos = origin = video_mem_start = base;
scr_end = video_mem_end = base + screen_size;
vc_scrbuf[currcons] = (unsigned short *) origin;
- gotoxy(currcons,0,0);
}
currcons = 0;
@@ -1002,6 +997,7 @@ void con_init(void)
a=inb_p(0x61);
outb_p(a|0x80,0x61);
outb_p(a,0x61);
+ return kmem_start;
}
void kbdsave(int new_console)
@@ -1108,7 +1104,7 @@ int do_screendump(int arg)
verify_area(buf,2+video_num_columns*video_num_lines);
currcons = get_fs_byte(buf+1);
- if ((currcons<0) || (currcons>NR_CONSOLES))
+ if ((currcons<0) || (currcons>=NR_CONSOLES))
return -EIO;
put_fs_byte((char)(video_num_lines),buf++);
put_fs_byte((char)(video_num_columns),buf++);
diff --git a/kernel/chr_drv/lp.c b/kernel/chr_drv/lp.c
index ed56ce1..4643c27 100644
--- a/kernel/chr_drv/lp.c
+++ b/kernel/chr_drv/lp.c
@@ -122,7 +122,7 @@ static struct file_operations lp_fops = {
lp_release
};
-void lp_init(void)
+long lp_init(long kmem_start)
{
int offset = 0;
unsigned int testvalue = 0;
@@ -145,4 +145,5 @@ void lp_init(void)
}
if (count == 0)
printk("lp_init: no lp devices found\n");
+ return kmem_start;
}
diff --git a/kernel/chr_drv/mem.c b/kernel/chr_drv/mem.c
index db53a8e..1432c84 100644
--- a/kernel/chr_drv/mem.c
+++ b/kernel/chr_drv/mem.c
@@ -241,9 +241,10 @@ static struct file_operations mem_fops = {
NULL /* no special release code */
};
-void chr_dev_init(void)
+long chr_dev_init(long kmem_start)
{
chrdev_fops[1] = &mem_fops;
- tty_init();
- lp_init();
+ kmem_start = tty_init(kmem_start);
+ kmem_start = lp_init(kmem_start);
+ return kmem_start;
}
diff --git a/kernel/chr_drv/serial.c b/kernel/chr_drv/serial.c
index f0bb652..b9113a3 100644
--- a/kernel/chr_drv/serial.c
+++ b/kernel/chr_drv/serial.c
@@ -9,7 +9,7 @@
*
* This module implements the rs232 io functions
* void rs_write(struct tty_struct * queue);
- * void rs_init(void);
+ * long rs_init(long);
* and all interrupts pertaining to serial IO.
*/
@@ -39,8 +39,7 @@ int port_table[] = {
PORT_UNKNOWN,
PORT_UNKNOWN,
PORT_UNKNOWN
-};
-
+};
static void modem_status_intr(unsigned line, unsigned port, struct tty_struct * tty)
{
@@ -48,11 +47,12 @@ static void modem_status_intr(unsigned line, unsigned port, struct tty_struct *
if ((status & 0x88) == 0x08 && tty->pgrp > 0)
kill_pg(tty->pgrp,SIGHUP,1);
-
+#if 0
if ((status & 0x10) == 0x10)
tty->stopped = 0;
else
tty->stopped = 1;
+#endif
}
/*
@@ -89,17 +89,11 @@ static void send_intr(unsigned line, unsigned port, struct tty_struct * tty)
static void receive_intr(unsigned line, unsigned port, struct tty_struct * tty)
{
- if (FULL(tty->read_q))
- return;
-
- outb_p((inb(port+4) & 0x0d), port+4);
-
- do {
+ while (!FULL(tty->read_q)) {
+ if (!(inb(port+5) & 1))
+ break;
PUTCH(inb(port),tty->read_q);
- } while ((inb(port+5) & 0x01 != 0) && !FULL(tty->read_q));
-
- outb_p((inb(port+4) | 0x02), port+4);
-
+ };
timer_active |= (1<<(SER1_TIMER-1))<<line;
}
@@ -145,7 +139,7 @@ void do_IRQ3(void)
}
/*
- * IRQ4 normally handles com1 and com2
+ * IRQ4 normally handles com1 and com3
*/
void do_IRQ4(void)
{
@@ -291,7 +285,7 @@ void serial_open(unsigned line)
sti();
}
-void rs_init(void)
+long rs_init(long kmem_start)
{
/* SERx_TIMER timers are used for receiving: timeout is always 0 (immediate) */
timer_table[SER1_TIMER].fn = com1_timer;
@@ -318,6 +312,7 @@ void rs_init(void)
init(tty_table[66].read_q->data, 3);
init(tty_table[67].read_q->data, 4);
outb(inb_p(0x21)&0xE7,0x21);
+ return kmem_start;
}
/*
diff --git a/kernel/chr_drv/tty_io.c b/kernel/chr_drv/tty_io.c
index e5cb171..f2b88df 100644
--- a/kernel/chr_drv/tty_io.c
+++ b/kernel/chr_drv/tty_io.c
@@ -11,16 +11,15 @@
* Kill-line thanks to John T Kohl, who also corrected VMIN = VTIME = 0.
*/
-#include <linux/ctype.h>
#include <errno.h>
#include <signal.h>
-#include <unistd.h>
#include <fcntl.h>
#define ALRMMASK (1<<(SIGALRM-1))
#include <linux/sched.h>
#include <linux/tty.h>
+#include <linux/ctype.h>
#include <asm/io.h>
#include <asm/segment.h>
#include <asm/system.h>
@@ -32,14 +31,14 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
-#define QUEUES (3*(MAX_CONSOLES+NR_SERIALS+2*NR_PTYS))
-static struct tty_queue tty_queues[QUEUES];
+#define QUEUES (3*(NR_CONSOLES+NR_SERIALS+2*NR_PTYS))
+static struct tty_queue * tty_queues;
struct tty_struct tty_table[256];
#define con_queues tty_queues
-#define rs_queues ((3*MAX_CONSOLES) + tty_queues)
-#define mpty_queues ((3*(MAX_CONSOLES+NR_SERIALS)) + tty_queues)
-#define spty_queues ((3*(MAX_CONSOLES+NR_SERIALS+NR_PTYS)) + tty_queues)
+#define rs_queues ((3*NR_CONSOLES) + tty_queues)
+#define mpty_queues ((3*(NR_CONSOLES+NR_SERIALS)) + tty_queues)
+#define spty_queues ((3*(NR_CONSOLES+NR_SERIALS+NR_PTYS)) + tty_queues)
#define con_table tty_table
#define rs_table (64+tty_table)
@@ -58,13 +57,7 @@ struct tty_struct * redirect = NULL;
* these are the tables used by the machine code handlers.
* you can implement virtual consoles.
*/
-struct tty_queue * table_list[]={
- con_queues + 0, con_queues + 1,
- rs_queues + 0, rs_queues + 1,
- rs_queues + 3, rs_queues + 4,
- rs_queues + 6, rs_queues + 7,
- rs_queues + 9, rs_queues + 10
-};
+struct tty_queue * table_list[] = { NULL, NULL };
void change_console(unsigned int new_console)
{
@@ -121,12 +114,12 @@ void copy_to_cooked(struct tty_struct * tty)
if (I_UCLC(tty))
c=tolower(c);
if (L_CANON(tty)) {
- if ((KILL_CHAR(tty) != _POSIX_VDISABLE) &&
+ if ((KILL_CHAR(tty) != __DISABLED_CHAR) &&
(c==KILL_CHAR(tty))) {
/* deal with killing the input line */
while(!(EMPTY(tty->secondary) ||
(c=LAST(tty->secondary))==10 ||
- ((EOF_CHAR(tty) != _POSIX_VDISABLE) &&
+ ((EOF_CHAR(tty) != __DISABLED_CHAR) &&
(c==EOF_CHAR(tty))))) {
if (L_ECHO(tty)) {
if (c<32) {
@@ -143,11 +136,11 @@ void copy_to_cooked(struct tty_struct * tty)
}
continue;
}
- if ((ERASE_CHAR(tty) != _POSIX_VDISABLE) &&
+ if ((ERASE_CHAR(tty) != __DISABLED_CHAR) &&
(c==ERASE_CHAR(tty))) {
if (EMPTY(tty->secondary) ||
(c=LAST(tty->secondary))==10 ||
- ((EOF_CHAR(tty) != _POSIX_VDISABLE) &&
+ ((EOF_CHAR(tty) != __DISABLED_CHAR) &&
(c==EOF_CHAR(tty))))
continue;
if (L_ECHO(tty)) {
@@ -166,12 +159,12 @@ void copy_to_cooked(struct tty_struct * tty)
}
}
if (I_IXON(tty)) {
- if ((STOP_CHAR(tty) != _POSIX_VDISABLE) &&
+ if ((STOP_CHAR(tty) != __DISABLED_CHAR) &&
(c==STOP_CHAR(tty))) {
tty->stopped=1;
continue;
}
- if ((START_CHAR(tty) != _POSIX_VDISABLE) &&
+ if ((START_CHAR(tty) != __DISABLED_CHAR) &&
(c==START_CHAR(tty))) {
tty->stopped=0;
TTY_WRITE_FLUSH(tty);
@@ -179,27 +172,27 @@ void copy_to_cooked(struct tty_struct * tty)
}
}
if (L_ISIG(tty)) {
- if ((INTR_CHAR(tty) != _POSIX_VDISABLE) &&
+ if ((INTR_CHAR(tty) != __DISABLED_CHAR) &&
(c==INTR_CHAR(tty))) {
kill_pg(tty->pgrp, SIGINT, 1);
continue;
}
- if ((QUIT_CHAR(tty) != _POSIX_VDISABLE) &&
+ if ((QUIT_CHAR(tty) != __DISABLED_CHAR) &&
(c==QUIT_CHAR(tty))) {
kill_pg(tty->pgrp, SIGQUIT, 1);
continue;
}
- if ((SUSPEND_CHAR(tty) != _POSIX_VDISABLE) &&
+ if ((SUSPEND_CHAR(tty) != __DISABLED_CHAR) &&
(c==SUSPEND_CHAR(tty))) {
if (!is_orphaned_pgrp(tty->pgrp))
kill_pg(tty->pgrp, SIGTSTP, 1);
continue;
}
}
- if (c==10 || (EOF_CHAR(tty) != _POSIX_VDISABLE &&
+ if (c==10 || (EOF_CHAR(tty) != __DISABLED_CHAR &&
c==EOF_CHAR(tty)))
tty->secondary->data++;
- if ((L_ECHO(tty) || L_ECHONL(tty)) && (c==10)) {
+ if ((L_ECHO(tty) || (L_CANON(tty) && L_ECHONL(tty))) && (c==10)) {
PUTCH(10,tty->write_q);
PUTCH(13,tty->write_q);
} else if (L_ECHO(tty)) {
@@ -311,10 +304,10 @@ static int read_chan(unsigned int channel, struct file * file, char * buf, int n
sti();
do {
c = GETCH(tty->secondary);
- if ((EOF_CHAR(tty) != _POSIX_VDISABLE &&
+ if ((EOF_CHAR(tty) != __DISABLED_CHAR &&
c==EOF_CHAR(tty)) || c==10)
tty->secondary->data--;
- if ((EOF_CHAR(tty) != _POSIX_VDISABLE &&
+ if ((EOF_CHAR(tty) != __DISABLED_CHAR &&
c==EOF_CHAR(tty)) && L_CANON(tty))
break;
else {
@@ -543,10 +536,14 @@ static struct file_operations ttyx_fops = {
tty_release
};
-void tty_init(void)
+long tty_init(long kmem_start)
{
int i;
+ tty_queues = (struct tty_queue *) kmem_start;
+ kmem_start += QUEUES * (sizeof (struct tty_queue));
+ table_list[0] = con_queues + 0;
+ table_list[1] = con_queues + 1;
chrdev_fops[4] = &ttyx_fops;
chrdev_fops[5] = &tty_fops;
for (i=0 ; i < QUEUES ; i++)
@@ -566,7 +563,7 @@ void tty_init(void)
NULL, NULL, NULL, NULL
};
}
- con_init();
+ kmem_start = con_init(kmem_start);
for (i = 0 ; i<NR_CONSOLES ; i++) {
con_table[i] = (struct tty_struct) {
{ICRNL, /* change incoming CR to NL */
@@ -637,7 +634,8 @@ void tty_init(void)
spty_queues+0+i*3,spty_queues+1+i*3,spty_queues+2+i*3
};
}
- rs_init();
+ kmem_start = rs_init(kmem_start);
printk("%d virtual consoles\n\r",NR_CONSOLES);
printk("%d pty's\n\r",NR_PTYS);
+ return kmem_start;
}
diff --git a/kernel/chr_drv/vt.c b/kernel/chr_drv/vt.c
index 0514601..d026a41 100644
--- a/kernel/chr_drv/vt.c
+++ b/kernel/chr_drv/vt.c
@@ -24,9 +24,8 @@
* console (vt and kd) routines, as defined by usl svr4 manual
*/
-struct vt_cons vt_cons[MAX_CONSOLES];
+struct vt_cons vt_cons[NR_CONSOLES];
-extern int NR_CONSOLES;
extern unsigned char kleds;
extern unsigned char kraw;
extern unsigned char ke0;
diff --git a/kernel/chr_drv/vt_kern.h b/kernel/chr_drv/vt_kern.h
index 2c7116c..5d72a3a 100644
--- a/kernel/chr_drv/vt_kern.h
+++ b/kernel/chr_drv/vt_kern.h
@@ -10,6 +10,6 @@ extern struct vt_cons {
unsigned char vc_kbdraw;
unsigned char vc_kbde0;
unsigned char vc_kbdleds;
-} vt_cons[MAX_CONSOLES];
+} vt_cons[NR_CONSOLES];
#endif /* _VT_KERN_H */
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 7b6905d..8e1fd25 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -260,6 +260,8 @@ int sys_ptrace(long request, long pid, long addr, long data)
}
if (!(child->flags & PF_PTRACED) || child->state != TASK_STOPPED)
return -ESRCH;
+ if (child->p_pptr != current)
+ return -ESRCH;
switch (request) {
/* when I and D space are seperate, these will need to be fixed. */
@@ -354,6 +356,9 @@ int sys_ptrace(long request, long pid, long addr, long data)
child->flags &= ~PF_PTRACED;
child->signal=0;
child->state = 0;
+ REMOVE_LINKS(child);
+ child->p_pptr = child->p_opptr;
+ SET_LINKS(child);
/* make sure the single step bit is not set. */
tmp = get_stack_long(child, 4*EFL-MAGICNUMBER) & ~TRAP_FLAG;
put_stack_long(child, 4*EFL-MAGICNUMBER,tmp);
diff --git a/kernel/sys.c b/kernel/sys.c
index 75a86ba..bb086fa 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -12,7 +12,7 @@
#include <linux/config.h>
#include <asm/segment.h>
#include <sys/times.h>
-#include <sys/utsname.h>
+#include <linux/utsname.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <linux/string.h>
@@ -443,19 +443,34 @@ int in_group_p(gid_t grp)
return 0;
}
-static struct utsname thisname = {
+static struct new_utsname thisname = {
UTS_SYSNAME, UTS_NODENAME, UTS_RELEASE, UTS_VERSION, UTS_MACHINE
};
-int sys_uname(struct utsname * name)
+int sys_newuname(struct new_utsname * name)
{
- int i;
+ if (!name)
+ return -EFAULT;
+ verify_area(name, sizeof *name);
+ memcpy_tofs(name,&thisname,sizeof *name);
+ return 0;
+}
+int sys_uname(struct old_utsname * name)
+{
if (!name)
return -EINVAL;
verify_area(name,sizeof *name);
- for(i=0;i<sizeof *name;i++)
- put_fs_byte(((char *) &thisname)[i],i+(char *) name);
+ memcpy_tofs(&name->sysname,&thisname.sysname,__OLD_UTS_LEN);
+ put_fs_byte(0,name->sysname+__OLD_UTS_LEN);
+ memcpy_tofs(&name->nodename,&thisname.nodename,__OLD_UTS_LEN);
+ put_fs_byte(0,name->nodename+__OLD_UTS_LEN);
+ memcpy_tofs(&name->release,&thisname.release,__OLD_UTS_LEN);
+ put_fs_byte(0,name->release+__OLD_UTS_LEN);
+ memcpy_tofs(&name->version,&thisname.version,__OLD_UTS_LEN);
+ put_fs_byte(0,name->version+__OLD_UTS_LEN);
+ memcpy_tofs(&name->machine,&thisname.machine,__OLD_UTS_LEN);
+ put_fs_byte(0,name->machine+__OLD_UTS_LEN);
return 0;
}
@@ -468,15 +483,13 @@ int sys_sethostname(char *name, int len)
if (!suser())
return -EPERM;
- if (len > MAXHOSTNAMELEN)
+ if (len > __NEW_UTS_LEN)
return -EINVAL;
for (i=0; i < len; i++) {
if ((thisname.nodename[i] = get_fs_byte(name+i)) == 0)
- break;
- }
- if (thisname.nodename[i]) {
- thisname.nodename[i>MAXHOSTNAMELEN ? MAXHOSTNAMELEN : i] = 0;
+ return 0;
}
+ thisname.nodename[__NEW_UTS_LEN] = 0;
return 0;
}
diff --git a/lib/_exit.c b/lib/_exit.c
index ac48d1a..4b1985a 100644
--- a/lib/_exit.c
+++ b/lib/_exit.c
@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
volatile void _exit(int exit_code)
{
diff --git a/lib/close.c b/lib/close.c
index 3ef965d..31bb780 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
_syscall1(int,close,int,fd)
diff --git a/lib/dup.c b/lib/dup.c
index 495c6e3..fddb3c3 100644
--- a/lib/dup.c
+++ b/lib/dup.c
@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
_syscall1(int,dup,int,fd)
diff --git a/lib/execve.c b/lib/execve.c
index 7669b50..996b0ea 100644
--- a/lib/execve.c
+++ b/lib/execve.c
@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
_syscall3(int,execve,const char *,file,char **,argv,char **,envp)
diff --git a/lib/itimer.c b/lib/itimer.c
index 9692eeb..69cf1eb 100644
--- a/lib/itimer.c
+++ b/lib/itimer.c
@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
#include <sys/time.h>
_syscall2(int,getitimer,int,which,struct itimerval *,value)
diff --git a/lib/open.c b/lib/open.c
index 5972807..55c82ec 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
#include <stdarg.h>
int open(const char * filename, int flag, ...)
diff --git a/lib/setsid.c b/lib/setsid.c
index 601fcfc..f9f056f 100644
--- a/lib/setsid.c
+++ b/lib/setsid.c
@@ -5,7 +5,8 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <sys/types.h>
+#include <linux/unistd.h>
_syscall0(pid_t,setsid)
diff --git a/lib/wait.c b/lib/wait.c
index e02dfdf..114ef33 100644
--- a/lib/wait.c
+++ b/lib/wait.c
@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
#include <sys/wait.h>
_syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
diff --git a/lib/write.c b/lib/write.c
index 69d4ab3..5269cc6 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -5,7 +5,8 @@
*/
#define __LIBRARY__
-#include <unistd.h>
+#include <linux/unistd.h>
+#include <sys/types.h>
_syscall3(int,write,int,fd,const char *,buf,off_t,count)
diff --git a/mm/memory.c b/mm/memory.c
index 1417bc9..801dd15 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -716,6 +716,9 @@ void mem_init(long start_mem, long end_mem)
{
int i;
+ end_mem &= 0xfffff000;
+ start_mem += 0xfff;
+ start_mem &= 0xfffff000;
swap_device = 0;
swap_file = NULL;
HIGH_MEMORY = end_mem;
diff --git a/mm/mmap.c b/mm/mmap.c
index a8ea628..ae1fd66 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3,7 +3,7 @@
*
* Written by obz.
*/
-#include <sys/stat.h>
+#include <linux/stat.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <asm/segment.h>
diff --git a/mm/swap.c b/mm/swap.c
index fa933e3..f968e05 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -10,8 +10,8 @@
*/
#include <errno.h>
-#include <sys/stat.h>
+#include <linux/stat.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/sched.h>
diff --git a/net/socket.c b/net/socket.c
index 70472b5..b5ba72e 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2,10 +2,10 @@
#include <errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
+#include <linux/stat.h>
#include <asm/system.h>
#include <asm/segment.h>
#include <sys/socket.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include "kern_sock.h"
diff --git a/net/unix.c b/net/unix.c
index 441d709..4abe790 100644
--- a/net/unix.c
+++ b/net/unix.c
@@ -3,11 +3,11 @@
#include <linux/string.h>
#include <linux/sched.h>
#include <linux/kernel.h>
+#include <linux/stat.h>
#include <asm/system.h>
#include <asm/segment.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include "kern_sock.h"