diff -Naur linux-0.01-rm-3.2/fs/fcntl.c linux-0.01-rm-3.3/fs/fcntl.c --- linux-0.01-rm-3.2/fs/fcntl.c 2007-12-25 10:39:00.000000000 +0100 +++ linux-0.01-rm-3.3/fs/fcntl.c 2007-12-29 13:55:54.000000000 +0100 @@ -67,3 +67,25 @@ return -1; } } + + +int sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + struct file * filp; + + if (fd >= NR_OPEN || !(filp = current->filp[fd])) + return -EBADF; + + switch(cmd) + { + case F_GETLK64: + case F_SETLK64: + case F_SETLKW64: + return -ENOSYS; + + default: + return sys_fcntl(fd,cmd,arg); + } + +} + diff -Naur linux-0.01-rm-3.2/fs/stat.c linux-0.01-rm-3.3/fs/stat.c --- linux-0.01-rm-3.2/fs/stat.c 2007-12-25 10:39:00.000000000 +0100 +++ linux-0.01-rm-3.3/fs/stat.c 2007-12-29 12:04:36.000000000 +0100 @@ -40,6 +40,11 @@ return i; } +int sys_lstat(char* filename, struct stat * statbuf) +{ + return sys_stat(filename,statbuf); +} + int sys_fstat(unsigned int fd, struct stat * statbuf) { struct file * f; @@ -49,3 +54,66 @@ return -ENOENT; return cp_stat(inode,statbuf); } + + +static int cp_stat64(struct m_inode * inode, struct stat64 * statbuf) +{ + struct stat64 tmp; + int i; + + verify_area(statbuf,sizeof (* statbuf)); + tmp.st_dev = inode->i_dev; + tmp.st_ino = inode->i_num; + tmp.st_mode = inode->i_mode; + tmp.st_nlink = inode->i_nlinks; + tmp.st_uid = inode->i_uid; + tmp.st_gid = inode->i_gid; + tmp.st_rdev = inode->i_zone[0]; + tmp.st_size = inode->i_size; + tmp.st_atime = inode->i_atime; + tmp.st_mtime = inode->i_mtime; + tmp.st_ctime = inode->i_ctime; + for (i=0 ; i= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode)) + return -ENOENT; + return cp_stat64(inode,statbuf); +} + +int sys_lstat64(char* filename, struct stat * statbuf) +{ + return sys_stat64(filename,statbuf); +} + +int sys_oldstat() +{ + printk("calling obsolete system call oldstat\n"); + return 0; +} + +int sys_oldfstat() +{ + printk("calling obsolete system call oldfstat\n"); + return 0; +} + diff -Naur linux-0.01-rm-3.2/fs/sys_getdents.c linux-0.01-rm-3.3/fs/sys_getdents.c --- linux-0.01-rm-3.2/fs/sys_getdents.c 2007-12-25 10:46:22.000000000 +0100 +++ linux-0.01-rm-3.3/fs/sys_getdents.c 2007-12-28 22:17:03.000000000 +0100 @@ -54,6 +54,50 @@ return 0; } +static int minix_getdents64(struct m_inode * inode, struct file * filp, + struct dirent64 * dirent, int count) +{ + unsigned int offset,i; + char c; + struct buffer_head * bh; + struct dir_entry * de; + + if (!inode ||/* !inode->i_sb ||*/ !S_ISDIR(inode->i_mode)) + return -EBADF;/* + info = &inode->i_sb->u.minix_sb; + if (filp->f_pos & (info->s_dirsize - 1)) + return -EBADF;*/ + while (filp->f_pos < inode->i_size) { + offset = filp->f_pos & 1023; + bh = read_file_block(inode,(filp->f_pos)/BLOCK_SIZE); + if (!bh) { + filp->f_pos += 1024-offset; + continue; + } + while (offset < 1024 && filp->f_pos < inode->i_size) { + de = (struct dir_entry *) (offset + bh->b_data); + offset += sizeof(struct dir_entry);//info->s_dirsize; + filp->f_pos += sizeof(struct dir_entry); + if (de->inode) { + for (i = 0; i < NAME_LEN; i++) + if ((c = de->name[i]) != 0) + put_fs_byte(c,i+dirent->d_name); + else + break; + if (i) { + put_fs_long(de->inode,&dirent->d_ino); + put_fs_byte(0,i+dirent->d_name); + put_fs_word(i,&dirent->d_reclen); + brelse(bh); + return i; + } + } + } + brelse(bh); + } + return 0; +} + int sys_getdents(unsigned int fd, struct dirent *dirp, unsigned int count) { struct file * file; @@ -66,3 +110,15 @@ return minix_getdents(inode,file,dirp,count); } +int sys_getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int count) +{ + struct file * file; + struct m_inode * inode; + if (fd >= NR_OPEN || !(file = current->filp[fd]) || + !(inode = file->f_inode)) + return -EBADF; + + verify_area(dirp, sizeof (*dirp)); + return minix_getdents64(inode,file,dirp,count); +} + diff -Naur linux-0.01-rm-3.2/include/dirent.h linux-0.01-rm-3.3/include/dirent.h --- linux-0.01-rm-3.2/include/dirent.h 2007-12-25 10:39:01.000000000 +0100 +++ linux-0.01-rm-3.3/include/dirent.h 2007-12-28 22:06:30.000000000 +0100 @@ -3,35 +3,35 @@ #define __DIRENT_H #include - +#include #define NAME_MAX NAME_LEN struct dirent{ -// long d_fileno; long d_ino; off_t d_off; unsigned short d_reclen; -// unsigned char d_type; char d_name[256]; -// struct dir_entry d_kent; +}; + +struct dirent64 { + uint64_t d_ino; + int64_t d_off; + uint16_t d_reclen; + unsigned char d_type; + char d_name[256]; }; struct __DIR{ - struct dirent d_dent; + struct dirent64 d_dent; int d_pos; int d_fd; }; #define DIR struct __DIR -//#define dirent dir_entry - -//#define D_NAMELEN(d) 256 DIR *opendir (const char *name); - int closedir (DIR *dir); - struct dirent *readdir (DIR *dir); #endif diff -Naur linux-0.01-rm-3.2/include/fcntl.h linux-0.01-rm-3.3/include/fcntl.h --- linux-0.01-rm-3.2/include/fcntl.h 2007-12-25 10:39:01.000000000 +0100 +++ linux-0.01-rm-3.3/include/fcntl.h 2007-12-29 13:58:46.000000000 +0100 @@ -28,6 +28,9 @@ #define F_GETLK 5 /* not implemented */ #define F_SETLK 6 #define F_SETLKW 7 +#define F_GETLK64 12 +#define F_SETLK64 13 +#define F_SETLKW64 14 /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ diff -Naur linux-0.01-rm-3.2/include/linux/sys.h linux-0.01-rm-3.3/include/linux/sys.h --- linux-0.01-rm-3.2/include/linux/sys.h 2007-12-25 10:39:01.000000000 +0100 +++ linux-0.01-rm-3.3/include/linux/sys.h 2007-12-29 12:47:00.000000000 +0100 @@ -16,7 +16,7 @@ extern int sys_chmod(); extern int sys_chown(); extern int sys_break(); -extern int sys_stat(); +extern int sys_oldstat(); extern int sys_lseek(); extern int sys_getpid(); extern int sys_mount(); @@ -26,7 +26,7 @@ extern int sys_stime(); extern int sys_ptrace(); extern int sys_alarm(); -extern int sys_fstat(); +extern int sys_oldfstat(); extern int sys_pause(); extern int sys_utime(); extern int sys_stty(); @@ -57,7 +57,7 @@ extern int sys_mpx(); extern int sys_setpgid(); extern int sys_ulimit(); -extern int sys_uname(); +extern int sys_oldolduname(); extern int sys_umask(); extern int sys_chroot(); extern int sys_ustat(); @@ -65,37 +65,80 @@ extern int sys_getppid(); extern int sys_getpgrp(); extern int sys_setsid(); +extern int sys_stat(); +extern int sys_lstat(); +extern int sys_fstat(); +extern int sys_uname(); extern int sys_getdents(); +extern int sys_stat64(); +extern int sys_lstat64(); +extern int sys_fstat64(); +extern int sys_getdents64(); +extern int sys_fcntl64(); extern int sys_null(); /* not implemented sys_call */ 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, sys_unlink, sys_execve, sys_chdir, sys_time, sys_mknod, sys_chmod, -sys_chown, sys_break, sys_stat, sys_lseek, sys_getpid, sys_mount, +sys_chown, sys_break, sys_oldstat, sys_lseek, sys_getpid, sys_mount, sys_umount, sys_setuid, sys_getuid, sys_stime, sys_ptrace, sys_alarm, -sys_fstat, sys_pause, sys_utime, sys_stty, sys_gtty, sys_access, +sys_oldfstat, sys_pause, sys_utime, sys_stty, sys_gtty, sys_access, sys_nice, sys_ftime, sys_sync, sys_kill, sys_rename, sys_mkdir, sys_rmdir, sys_dup, sys_pipe, sys_times, sys_prof, sys_brk, sys_setgid, sys_getgid, sys_signal, sys_geteuid, sys_getegid, sys_acct, sys_phys, sys_lock, sys_ioctl, sys_fcntl, sys_mpx, sys_setpgid, sys_ulimit, -sys_uname, sys_umask, sys_chroot, sys_ustat, sys_dup2, sys_getppid, +sys_oldolduname, sys_umask, sys_chroot, sys_ustat, sys_dup2, sys_getppid, sys_getpgrp,sys_setsid, sys_null /*67*/,sys_null,sys_null, -sys_null /*70*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*80*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*90*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*100*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*110*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*120*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*130*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*140*/,sys_getdents,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null, -sys_null /*150*/,sys_null,sys_null,sys_null,sys_null,sys_null,sys_null, -sys_null,sys_null,sys_null + +/* 70 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 80 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 90 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 100 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_stat,sys_lstat,sys_fstat,sys_null, +/* 110 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 120 */sys_null,sys_null,sys_uname,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 130 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 140 */sys_null,sys_getdents,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 150 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 160 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 170 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 180 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 190 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_stat64,sys_lstat64,sys_fstat64,sys_null,sys_null, +/* 200 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 210 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 220 */sys_getdents64,sys_fcntl64,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 230 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 240 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 250 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 260 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 270 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 280 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 290 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 300 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null, +/* 310 */sys_null,sys_null,sys_null,sys_null,sys_null, +sys_null,sys_null,sys_null,sys_null,sys_null }; + diff -Naur linux-0.01-rm-3.2/include/sys/stat.h linux-0.01-rm-3.3/include/sys/stat.h --- linux-0.01-rm-3.2/include/sys/stat.h 2007-12-25 10:39:01.000000000 +0100 +++ linux-0.01-rm-3.3/include/sys/stat.h 2007-12-29 11:54:33.000000000 +0100 @@ -2,19 +2,63 @@ #define _SYS_STAT_H #include +#include struct stat { - dev_t st_dev; - ino_t st_ino; - umode_t st_mode; - nlink_t st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - off_t st_size; - time_t st_atime; - time_t st_mtime; - time_t st_ctime; + uint16_t st_dev; + uint16_t __pad1; + unsigned long st_ino; + uint16_t st_mode; + uint16_t st_nlink; + uint16_t st_uid; + uint16_t st_gid; + uint16_t st_rdev; + uint16_t __pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + time_t st_atime; + unsigned long __unused1; + time_t st_mtime; + unsigned long __unused2; + time_t st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +struct stat64 { + uint16_t st_dev; + unsigned char __pad0[10]; + +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + + uint32_t st_mode; + uint32_t st_nlink; + + unsigned long st_uid; + unsigned long st_gid; + + uint16_t st_rdev; + unsigned char __pad3[10]; + +__extension__ long long st_size __attribute__((__packed__)); + unsigned long st_blksize; + + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ + unsigned long __pad4; /* future possible st_blocks high bits */ + + time_t st_atime; + unsigned long __pad5; + + time_t st_mtime; + unsigned long __pad6; + + time_t st_ctime; + unsigned long __pad7; /* will be high 32 bits of ctime someday */ + +__extension__ unsigned long long st_ino __attribute__((__packed__)); }; #define S_IFMT 00170000 @@ -49,10 +93,10 @@ #define S_IXOTH 00001 extern int chmod(const char *_path, mode_t mode); -extern int fstat(int fildes, struct stat *stat_buf); +extern int fstat64(int fildes, struct stat64 *stat_buf); extern int mkdir(const char *_path, mode_t mode); extern int mkfifo(const char *_path, mode_t mode); -extern int stat(const char *filename, struct stat *stat_buf); +extern int stat64(const char *filename, struct stat64 *stat_buf); extern mode_t umask(mode_t mask); #endif diff -Naur linux-0.01-rm-3.2/include/sys/utsname.h linux-0.01-rm-3.3/include/sys/utsname.h --- linux-0.01-rm-3.2/include/sys/utsname.h 2007-12-25 10:39:01.000000000 +0100 +++ linux-0.01-rm-3.3/include/sys/utsname.h 2007-12-26 12:34:54.000000000 +0100 @@ -1,16 +1,35 @@ -#ifndef _SYS_UTSNAME_H -#define _SYS_UTSNAME_H +#ifndef _SYS_UTSNAME_H +#define _SYS_UTSNAME_H 1 -#include +/* Length of the entries in `struct utsname' is 65. */ +#define _UTSNAME_LENGTH 65 +#define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH + +/* Linux provides as additional information in the `struct utsname' + the name of the current domain. Define _UTSNAME_DOMAIN_LENGTH + to a value != 0 to activate this entry. */ +#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH struct utsname { - char sysname[9]; - char nodename[9]; - char release[9]; - char version[9]; - char machine[9]; + /* Name of the implementation of the operating system. */ + char sysname[_UTSNAME_LENGTH]; + + /* Name of this node on the network. */ + char nodename[_UTSNAME_NODENAME_LENGTH]; + + /* Current release level of this implementation. */ + char release[_UTSNAME_LENGTH]; + /* Current version level of this release. */ + char version[_UTSNAME_LENGTH]; + + /* Name of the hardware type the system is running on. */ + char machine[_UTSNAME_LENGTH]; + + /* Name of the domain of this node on the network. */ + char domainname[_UTSNAME_DOMAIN_LENGTH]; }; -extern int uname(struct utsname * utsbuf); +extern int uname (struct utsname *__name); + #endif diff -Naur linux-0.01-rm-3.2/include/unistd.h linux-0.01-rm-3.3/include/unistd.h --- linux-0.01-rm-3.2/include/unistd.h 2007-12-25 10:39:01.000000000 +0100 +++ linux-0.01-rm-3.3/include/unistd.h 2007-12-29 12:46:02.000000000 +0100 @@ -75,7 +75,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 @@ -85,7 +85,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 @@ -116,15 +116,24 @@ #define __NR_mpx 56 #define __NR_setpgid 57 #define __NR_ulimit 58 -#define __NR_uname 59 +#define __NR_oldolduname 59 #define __NR_umask 60 #define __NR_chroot 61 #define __NR_ustat 62 #define __NR_dup2 63 #define __NR_getppid 64 #define __NR_getpgrp 65 -#define __NR_setsid 66 +#define __NR_setsid 66 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_uname 122 #define __NR_getdents 141 +#define __NR_stat64 195 +#define __NR_ltat64 196 +#define __NR_fstat64 197 +#define __NR_getdents64 220 +#define __NR_fcntl64 221 #define _syscall0(type,name) \ type name(void) \ @@ -224,8 +233,8 @@ int setuid(uid_t uid); int setgid(gid_t gid); void (*signal(int sig, void (*fn)(int)))(int); -int stat(const char * filename, struct stat * stat_buf); -int fstat(int fildes, struct stat * stat_buf); +int stat64(const char * filename, struct stat64 * stat_buf); +int fstat64(int fildes, struct stat64 * stat_buf); int stime(time_t * tptr); //int sync(void); time_t time(time_t * tloc); @@ -245,5 +254,6 @@ pid_t getpgrp(void); pid_t setsid(void); int getdents(unsigned int fd, struct dirent *dirp, unsigned int count); +int getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int count); #endif diff -Naur linux-0.01-rm-3.2/kernel/sys.c linux-0.01-rm-3.3/kernel/sys.c --- linux-0.01-rm-3.2/kernel/sys.c 2007-12-25 10:39:00.000000000 +0100 +++ linux-0.01-rm-3.3/kernel/sys.c 2007-12-31 15:08:12.000000000 +0100 @@ -193,10 +193,17 @@ return current->pgrp; } +int sys_oldolduname(void* v) +{ + printk("calling obsolete system call oldolduname\n"); + return -ENOSYS; +// return (0); +} + int sys_uname(struct utsname * name) { static struct utsname thisname = { - "linux .0","nodename","release ","version ","machine " + "linux 0.01-3.x","nodename","release ","3.x","i386" }; int i; @@ -215,8 +222,16 @@ return (old); } -int sys_null() +int sys_null(int nr) { + static int prev_nr=-2; + if (nr==174 || nr==175) return -ENOSYS; + + if (prev_nr!=nr) + { + prev_nr=nr; +// printk("system call num %d not available\n",nr); + } return -ENOSYS; } diff -Naur linux-0.01-rm-3.2/kernel/system_call.s linux-0.01-rm-3.3/kernel/system_call.s --- linux-0.01-rm-3.2/kernel/system_call.s 2007-12-25 10:39:00.000000000 +0100 +++ linux-0.01-rm-3.3/kernel/system_call.s 2007-12-27 14:34:10.000000000 +0100 @@ -45,7 +45,7 @@ restorer = 16 # address of info-restorer sig_fn = 20 # table of 32 signal addresses -nr_system_calls = 150 +nr_system_calls = 319 .globl system_call,sys_fork,timer_interrupt,hd_interrupt,sys_execve @@ -72,6 +72,14 @@ mov %dx,%es movl $0x17,%edx # fs points to local data space mov %dx,%fs + + movl sys_call_table(,%eax,4),%edx # if sys_null + cmpl $sys_null,%edx # then the syscall is not + jne 1f # implemented. + popl %edx # 1st argument is syscall nr + pushl %eax +1: + call *sys_call_table(,%eax,4) pushl %eax movl current,%eax