iput(ip);
}
+//PAGEBREAK!
// Allocate a new inode with the given type on device dev.
struct inode*
ialloc(uint dev, short type)
brelse(bp);
}
+//PAGEBREAK!
// Inode contents
//
// The contents (data) associated with each inode is stored
return 0;
}
+//PAGEBREAK!
// Paths
// Copy the next path element from path into name.
return path;
}
+static struct inode* _namei(char*, int, char*);
+
+struct inode*
+namei(char *path)
+{
+ char name[DIRSIZ];
+ return _namei(path, 0, name);
+}
+
+struct inode*
+nameiparent(char *path, char *name)
+{
+ return _namei(path, 1, name);
+}
+
// Look up and return the inode for a path name.
// If parent is set, return the inode for the parent
// and write the final path element to name, which
return ip;
}
-struct inode*
-namei(char *path)
-{
- char name[DIRSIZ];
- return _namei(path, 0, name);
-}
-
-struct inode*
-nameiparent(char *path, char *name)
-{
- return _namei(path, 1, name);
-}
}
int
-sys_fstat(void)
+sys_dup(void)
{
struct file *f;
- struct stat *st;
+ int fd;
- if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
+ if(argfd(0, 0, &f) < 0)
return -1;
- return filestat(f, st);
+ if((fd=fdalloc(f)) < 0)
+ return -1;
+ fileincref(f);
+ return fd;
}
int
return 0;
}
+int
+sys_fstat(void)
+{
+ struct file *f;
+ struct stat *st;
+
+ if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
+ return -1;
+ return filestat(f, st);
+}
+
// Create the path new as a link to the same inode as old.
int
sys_link(void)
return 1;
}
+//PAGEBREAK!
int
sys_unlink(void)
{
return 0;
}
-int
-sys_dup(void)
-{
- struct file *f;
- int fd;
-
- if(argfd(0, 0, &f) < 0)
- return -1;
- if((fd=fdalloc(f)) < 0)
- return -1;
- fileincref(f);
- return fd;
-}
-
int
sys_exec(void)
{