提交 e69077a7 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

sysfile.cc

上级 60205a16
...@@ -658,7 +658,7 @@ dirlookup(struct inode *dp, char *name) ...@@ -658,7 +658,7 @@ dirlookup(struct inode *dp, char *name)
// Write a new directory entry (name, inum) into the directory dp. // Write a new directory entry (name, inum) into the directory dp.
int int
dirlink(struct inode *dp, char *name, u32 inum) dirlink(struct inode *dp, const char *name, u32 inum)
{ {
dir_init(dp); dir_init(dp);
......
...@@ -112,7 +112,7 @@ void stati(struct inode*, struct stat*); ...@@ -112,7 +112,7 @@ void stati(struct inode*, struct stat*);
int writei(struct inode*, char*, u32, u32); int writei(struct inode*, char*, u32, u32);
struct inode* idup(struct inode*); struct inode* idup(struct inode*);
struct inode* nameiparent(char*, char*); struct inode* nameiparent(char*, char*);
int dirlink(struct inode*, char*, u32); int dirlink(struct inode*, const char*, u32);
void dir_init(struct inode *dp); void dir_init(struct inode *dp);
void dir_flush(struct inode *dp); void dir_flush(struct inode *dp);
...@@ -199,7 +199,7 @@ struct nskey { ...@@ -199,7 +199,7 @@ struct nskey {
u64 b; u64 b;
} ii; } ii;
char *s; char *s;
char *dirname; const char *dirname;
struct { struct {
u64 a; u64 a;
u64 b; u64 b;
...@@ -211,7 +211,7 @@ struct nskey { ...@@ -211,7 +211,7 @@ struct nskey {
#define KI(v) (struct nskey){type: nskey_int, u: { i: v }} #define KI(v) (struct nskey){type: nskey_int, u: { i: v }}
#define KII(x,y) (struct nskey){.type=nskey_ii,.u.ii.a=x,.u.ii.b=y} #define KII(x,y) (struct nskey){.type=nskey_ii,.u.ii.a=x,.u.ii.b=y}
#define KS(v) (struct nskey){.type=nskey_str,.u.s=v} #define KS(v) (struct nskey){.type=nskey_str,.u.s=v}
#define KD(v) (struct nskey){.type=nskey_dirname,.u.dirname=v} #define KD(v) (struct nskey){type: nskey_dirname, u: { dirname: v }}
#define KIIS(x,y,z) (struct nskey){.type=nskey_iis,.u.iis.a=x, \ #define KIIS(x,y,z) (struct nskey){.type=nskey_iis,.u.iis.a=x, \
.u.iis.b=y, \ .u.iis.b=y, \
.u.iis.s=z} .u.iis.s=z}
......
extern "C" {
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "mmu.h" #include "mmu.h"
...@@ -10,6 +11,8 @@ ...@@ -10,6 +11,8 @@
#include "file.h" #include "file.h"
#include "fcntl.h" #include "fcntl.h"
#include "cpu.h" #include "cpu.h"
#include "net.h"
}
// Fetch the nth word-sized system call argument as a file descriptor // Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file. // and return both the descriptor and the corresponding struct file.
...@@ -310,7 +313,7 @@ sys_open(void) ...@@ -310,7 +313,7 @@ sys_open(void)
} }
iunlock(ip); iunlock(ip);
f->type = FD_INODE; f->type = file::FD_INODE;
f->ip = ip; f->ip = ip;
f->off = 0; f->off = 0;
f->readable = !(omode & O_WRONLY); f->readable = !(omode & O_WRONLY);
...@@ -430,7 +433,7 @@ getsocket(int fd, struct file **ret) ...@@ -430,7 +433,7 @@ getsocket(int fd, struct file **ret)
struct file *f; struct file *f;
if (fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) if (fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
return -1; return -1;
if (f->type != FD_SOCKET) if (f->type != file::FD_SOCKET)
return -1; return -1;
*ret = f; *ret = f;
...@@ -453,7 +456,7 @@ allocsocket(struct file **rf, int *rfd) ...@@ -453,7 +456,7 @@ allocsocket(struct file **rf, int *rfd)
return fd; return fd;
} }
f->type = FD_SOCKET; f->type = file::FD_SOCKET;
f->off = 0; f->off = 0;
f->readable = 1; f->readable = 1;
f->writable = 1; f->writable = 1;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论