9 void free_inode(struct inode
*inode
)
11 /* Can not free current working directory */
12 if (inode
== inode
->i_fs
->pwd
)
19 struct inode
*new_inode(int mode
, int data_size
)
23 inode
= malloc(sizeof(*inode
));
26 memset(inode
, 0, sizeof(*inode
));
28 inode
->i_data
= malloc(data_size
);
33 memset(inode
->i_data
, 0, data_size
);
37 inode
->i_atime
= current_time
;
38 inode
->i_ctime
= current_time
;
39 inode
->i_mtime
= current_time
;
41 inode
->i_fs
= root_fs();
47 * get the inode for dname under given dir
49 * Return NULL if not found, or error if errors happened,
50 * or return inode if found.
52 * The current implementation has no cache, it would be
55 struct inode
* iget(const char *dname
, struct inode
*dir
)
57 struct inode
* inode
= ERR_PTR(-ENOSYS
);
59 if (dir
->i_op
&& dir
->i_op
->iget
)
60 inode
= dir
->i_op
->iget(dname
, dir
);
66 int sys_mknod(const char *pathname
, int mode
)
68 struct inode
*dir
= namei_parent(pathname
);
76 if (dir
->i_op
&& dir
->i_op
->mknod
) {
77 inode
= dir
->i_op
->mknod(dir
, get_base_name(pathname
), mode
);