mirror of
https://github.com/drasko/codezero.git
synced 2026-02-28 17:53:13 +01:00
A file can be created.
Now up to sys_write() in pager, which needs to be filled in.
This commit is contained in:
@@ -94,7 +94,8 @@ void handle_fs_requests(void)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("%s: Unrecognised ipc tag (%d) "
|
printf("%s: Unrecognised ipc tag (%d) "
|
||||||
"received. Ignoring.\n", __TASKNAME__, mr[MR_TAG]);
|
"received from tid: %d. Ignoring.\n", __TASKNAME__,
|
||||||
|
mr[MR_TAG], sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ struct vnode *memfs_vnode_mknod(struct vnode *v, const char *dirname,
|
|||||||
return newv;
|
return newv;
|
||||||
|
|
||||||
/* Initialise the vnode */
|
/* Initialise the vnode */
|
||||||
vfs_set_type(newv, S_IFDIR);
|
vfs_set_type(newv, mode);
|
||||||
|
|
||||||
/* Get the next directory entry available on the parent vnode */
|
/* Get the next directory entry available on the parent vnode */
|
||||||
if (v->dirbuf.npages * PAGE_SIZE <= v->size)
|
if (v->dirbuf.npages * PAGE_SIZE <= v->size)
|
||||||
|
|||||||
@@ -113,8 +113,10 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creating new node, file or directory */
|
/* Creating new file */
|
||||||
if (flags & O_CREAT) {
|
if (flags & O_CREAT) {
|
||||||
|
/* Make sure mode identifies a file */
|
||||||
|
mode |= S_IFREG;
|
||||||
if (IS_ERR(v = vfs_create(task, pdata, mode))) {
|
if (IS_ERR(v = vfs_create(task, pdata, mode))) {
|
||||||
retval = (int)v;
|
retval = (int)v;
|
||||||
goto out;
|
goto out;
|
||||||
@@ -182,6 +184,9 @@ int sys_mkdir(l4id_t sender, const char *pathname, unsigned int mode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure we create a directory */
|
||||||
|
mode |= S_IFDIR;
|
||||||
|
|
||||||
/* Create the directory or fail */
|
/* Create the directory or fail */
|
||||||
if (IS_ERR(v = vfs_create(task, pdata, mode)))
|
if (IS_ERR(v = vfs_create(task, pdata, mode)))
|
||||||
l4_ipc_return((int)v);
|
l4_ipc_return((int)v);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ static inline int l4_write(int fd, const void *buf, size_t count)
|
|||||||
write_mr(L4SYS_ARG2, count);
|
write_mr(L4SYS_ARG2, count);
|
||||||
|
|
||||||
/* Call pager with write() request. Check ipc error. */
|
/* Call pager with write() request. Check ipc error. */
|
||||||
if ((wrcnt = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_WRITE)) < 0) {
|
if ((wrcnt = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_WRITE)) < 0) {
|
||||||
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, wrcnt);
|
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, wrcnt);
|
||||||
return wrcnt;
|
return wrcnt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ int fileio(void)
|
|||||||
perror("OPEN");
|
perror("OPEN");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
printf("Created newfile.txt\n");
|
||||||
|
|
||||||
if ((int)(cnt = write(fd, str, strlen(str))) < 0) {
|
if ((int)(cnt = write(fd, str, strlen(str))) < 0) {
|
||||||
perror("WRITE");
|
perror("WRITE");
|
||||||
|
|||||||
Reference in New Issue
Block a user