static void do_mknod (vfs_task_t *client, vfsmsg_t *msg) { int dev; int ino; int dir_ino; char *n; n = msg->mknod.name; /* Find the directory node */ dir_ino = vfs_get_dir(client, &dev, msg->mknod.name); if (dir_ino < 0) { msg->mknod.ino = -1; return; } /* Create new node on device */ sendrec(devtab[dev], msg, sizeof(vfsmsg_t)); ino = msg->mknod.ino; /* Link the node */ msg->cmd = VFS_LINK; msg->link.name = n; msg->link.ino = ino; msg->link.dir_ino = dir_ino; sendrec(devtab[dev], msg, sizeof(vfsmsg_t)); if (msg->link.ino < 0) { msg->mknod.ino = -1; return; /* Cannot get node */ } msg->mknod.ino = ino; return; }
fs_node_t* vfs_mkdir(fs_node_t* node, char* name){ fs_node_t* dir = vfs_get_dir(node, name); if(dir == NULL){ vga_puts("vfs_mkdir(): invalid path\n"); return NULL; } fs_node_t* file = mk_empty_dnode(); strmov(file->name, basename(name)); file->link = dir->holds; dir->holds = file; return file; }
int vfs_get_node (vfs_task_t *client, int *dev, char* path) { int ino; char *bn; int len; ino = vfs_get_dir(client, dev, path); if (ino < 0) { return -1; } bn = basename(path, &len); if (len > 0) { ino = vfs_get_direntry(dev, ino, bn, len); } return ino; }
fs_node_t* vfs_touch(fs_node_t* node, char* name){ fs_node_t* dir = vfs_get_dir(node, name); if(dir == NULL) return NULL; fs_node_t* file = mk_empty_fnode(); strmov(file->name, basename(name)); fat_dir_t* entry = df_new_file(); if(entry == NULL) PANIC("kernel attempted to overwrite file in FAT"); int i; for(i = 0; i < 11; i++){ file->dos_name[i] = entry->name[i]; } file->link = dir->holds; dir->holds = file; return file; }