mkdir为make directories的简写,功能为在创建文件夹。可以通过多个参数来创建多个文件夹。注意:我们的操作系统是被烧录在系统光盘镜像中,光驱设备是一个只读设备。当系统启动之后,系统只能对硬盘进行写入操作,不能对光盘进行写入操作。也就是说,只能在/data/work/和/data/tool/这两个目录下才能执行mkdir命令。其实现如下:
session = malloc(sizeof(s_session)); session->current_path = malloc(SHELL_CMD_LEN); for (int i = 1; i < argc; ++i) { int params[2]; params[0] = 7; params[1] = (int) session; __asm__ volatile("int $0x80" :: "a"(params)); if (is_exist(args[i])) { printf("-bash : \"%s\": the folder already exists.\n", args[i]); } else { char f_name[0x200]; str_copy(args[i], f_name); int len = str_len(f_name); if (f_name[len - 1] != '/') { f_name[len] = '/'; f_name[len + 1] = '\0'; } int s = fs_create_folder(session->current_path, f_name, session->uid, session->uid, 01755); if (s == -1) { printf("-bash : \"%s\": permission denied.\n", args[i]); } else { printf("-bash : create folder \"%s\" sucessfully.\n", args[i]); } } } free(session->current_path); free(session);
运行结果:
源代码的下载地址为:
https https://github.com/magicworldos/lidqos.git git git@github.com:magicworldos/lidqos.git subverion https://github.com/magicworldos/lidqos branch v0.30
Copyright © 2015-2023 问渠网 辽ICP备15013245号