diff --git a/fs/open.c b/fs/open.c index a9525c21ad3076b11053d42a7d49d3e0d44de0b0..a7c982d95bcbdf8cb44afa2d25c1a12646d2034e 100644 --- a/fs/open.c +++ b/fs/open.c @@ -2,7 +2,7 @@ #include #include #include - +#include #include #include #include @@ -11,14 +11,50 @@ #include -int sys_utime(char * filename) { - printk("unimplement sys call utime\n"); +int sys_utime(char * filename, struct utimbuf * times) { + struct m_inode * inode; + long actime,modtime; + + if (!(inode=namei(filename))) + return -ENOENT; + + if (times) { + actime = get_fs_long((unsigned long *) ×->actime); + modtime = get_fs_long((unsigned long *) ×->modtime); + } + else { + actime = modtime = CURRENT_TIME; + } + + inode->i_atime = actime; + inode->i_mtime = modtime; + inode->i_dirt = 1; + iput(inode); return 0; } int sys_access(const char * filename,int mode) { - printk("unimplement sys call utime\n"); - return 0; + struct m_inode * inode; + int res, i_mode; + + mode &= 0007; + if (!(inode=namei(filename))) + return -EACCES; + + i_mode = res = inode->i_mode & 0777; + iput(inode); + if (current->uid == inode->i_uid) + res >>= 6; + else if (current->gid == inode->i_gid) + res >>= 6; + if ((res & 0007 & mode) == mode) + return 0; + + if ((!current->uid) && + (!(mode & 1) || (i_mode & 0111))) + return 0; + + return -EACCES; } int sys_ustat(int dev, struct ustat * ubuf) { diff --git a/include/unistd.h b/include/unistd.h index e114b7e3a1af43f99831304fd8af957079b7315f..f94fe4c8f48d300824d1779d5f2ed0c5f27a9f5f 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -9,6 +9,7 @@ #include #include +#include #ifdef __LIBRARY__ @@ -171,5 +172,6 @@ int rmdir(const char* pathname); time_t time(time_t * tloc); mode_t umask(mode_t mask); int uname(struct utsname * name); +int utime(const char * filename, struct utimbuf * times); #endif diff --git a/include/utime.h b/include/utime.h new file mode 100644 index 0000000000000000000000000000000000000000..43a6d2f7907fd0c2ad0b31ecd7649d43f0c07a9d --- /dev/null +++ b/include/utime.h @@ -0,0 +1,13 @@ +#ifndef _UTIME_H +#define _UTIME_H + +#include + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +extern int utime(const char *filename, struct utimbuf *times); + +#endif diff --git a/kernel/fork.c b/kernel/fork.c index 280319a1980dd75863e904dbaf204d04ec0dadcc..e20373477561c26d4ff8b8280f7570cf8d447dd8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2,6 +2,7 @@ #include #include +#include long last_pid = 0; @@ -62,20 +63,21 @@ int copy_process(int nr,long ebp,long edi,long esi,long gs,long none, return -EAGAIN; task[nr] = p; - *p = *current; + memcpy(p, current, sizeof(struct task_struct)); p->pid = last_pid; - p->priority = current->priority; p->counter = p->priority; + p->signal = 0; + p->alarm = 0; + p->leader = 0; - p->ldt[0] = current->ldt[0]; - p->ldt[1] = current->ldt[1]; - p->ldt[2] = current->ldt[2]; + p->utime = p->stime = 0; + p->cutime = p->cstime = 0; + p->start_time = jiffies; p->tss.back_link = 0; p->tss.esp0 = PAGE_SIZE + (long)p - 8; p->tss.ss0 = 0x10; - p->tss.cr3 = current->tss.cr3; p->tss.eip = eip; p->tss.eflags = eflags; p->tss.eax = 0; @@ -102,32 +104,22 @@ int copy_process(int nr,long ebp,long edi,long esi,long gs,long none, } for (i = 0; i < NR_OPEN; i++) { - p->filp[i] = current->filp[i]; if ((f = p->filp[i])) f->f_count++; } - p->tty = current->tty; - p->umask = current->umask; - - p->pwd = current->pwd; if (current->pwd) current->pwd->i_count++; - p->root = current->root; if (current->root) current->root->i_count++; - p->executable = current->executable; if (current->executable) current->executable->i_count++; - p->library = current->library; if (current->library) current->library->i_count++; - p->close_on_exec = current->close_on_exec; - set_tss_desc(gdt+(nr<<1)+FIRST_TSS_ENTRY,&(p->tss)); set_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY,&(p->ldt)); diff --git a/kernel/signal.c b/kernel/signal.c index eb451a9254b33ccf67b1a0d30b95cc7a46c4d333..50fb51f9a31bfd825abaaa97a2cd5e6ed4f9e1fc 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -73,9 +73,11 @@ int do_signal(long signr,long eax,long ebx, long ecx, long edx, long orig_eax, unsigned long * tmp_esp; + /* printk("pid: %d, signr: %x, eax=%d, oeax = %d, int=%d\n", current->pid, signr, eax, orig_eax, sa->sa_flags & SA_INTERRUPT); + */ if ((orig_eax != -1) && ((eax == -ERESTARTSYS) || (eax == -ERESTARTNOINTR))) {