Commit a5dcf393 authored by Linus Torvalds's avatar Linus Torvalds

32-bit inodes: patch4

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
parent 6cd3649b
......@@ -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>
......
......@@ -7,7 +7,7 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <linux/stat.h>
#include <asm/segment.h>
......
......@@ -5,7 +5,7 @@
*/
#include <linux/string.h>
#include <sys/stat.h>
#include <linux/stat.h>
#include <linux/sched.h>
#include <linux/kernel.h>
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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>
......
......@@ -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
......
......@@ -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 *);
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
/*
......
......@@ -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)
......
......@@ -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>
......
......@@ -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>
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
#define UTS_RELEASE "0.96a-10"
#define UTS_RELEASE "0.96a-35"
#define UTS_VERSION "05/22/92"
#define UTS_VERSION "06/17/92"
......@@ -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;
......
......@@ -100,4 +100,4 @@ struct lp_struct lp_table[] = {
* function prototypes
*/
extern void lp_init(void);
extern long lp_init(long);
#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
......@@ -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);
......@@ -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);
......
......@@ -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) \
......
#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
......@@ -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 */
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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);
......
......@@ -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++);
......
......@@ -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;
}
......@@ -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;
}
......@@ -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;
}
/*
......
......@@ -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;
}
......@@ -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;
......
......@@ -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 */
......@@ -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);
......
......@@ -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;
}
......
......@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
#include <unistd.h>
#include <linux/unistd.h>
volatile void _exit(int exit_code)
{
......
......@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
#include <unistd.h>
#include <linux/unistd.h>
_syscall1(int,close,int,fd)
......@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
#include <unistd.h>
#include <linux/unistd.h>
_syscall1(int,dup,int,fd)
......@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
#include <unistd.h>
#include <linux/unistd.h>
_syscall3(int,execve,const char *,file,char **,argv,char **,envp)
......@@ -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)
......
......@@ -5,7 +5,7 @@
*/
#define __LIBRARY__
#include <unistd.h>
#include <linux/unistd.h>
#include <stdarg.h>
int open(const char * filename, int flag, ...)
......
......@@ -5,7 +5,8 @@
*/
#define __LIBRARY__
#include <unistd.h>
#include <sys/types.h>
#include <linux/unistd.h>
_syscall0(pid_t,setsid)
......@@ -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)
......
......@@ -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)
......@@ -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;
......
......@@ -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>
......
......@@ -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>
......
......@@ -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"
......
......@@ -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"
......
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