更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
disk_shellcmd.c 文件参考

浏览源代码.

函数

INT32 osShellCmdPartInfo (INT32 argc, const CHAR **argv)
 
 SHELLCMD_ENTRY (partinfo_shellcmd, CMD_TYPE_EX, "partinfo", XARGS,(CmdCallBackFunc) osShellCmdPartInfo)
 

函数说明

◆ osShellCmdPartInfo()

INT32 osShellCmdPartInfo ( INT32  argc,
const CHAR **  argv 
)

在文件 disk_shellcmd.c59 行定义.

60{
61 struct Vnode *node = NULL;
62 los_part *part = NULL;
63 const CHAR *str = "/dev";
64 int ret;
65
66 if ((argc != 1) || (strncmp(argv[0], str, strlen(str)) != 0)) {//参数必须是 /dev 开头
67 PRINTK("Usage :\n");
68 PRINTK(" partinfo <dev_vnodename>\n");
69 PRINTK(" dev_vnodename : the name of dev\n");
70 PRINTK("Example:\n");
71 PRINTK(" partinfo /dev/sdap0 \n");
72
73 set_errno(EINVAL);
74 return -LOS_NOK;
75 }
76 VnodeHold();
77 ret = VnodeLookup(argv[0], &node, 0);//通过设备名称找到索引节点
78 if (ret < 0) {
79 PRINT_ERR("no part found\n");
80 VnodeDrop();
81 set_errno(ENOENT);
82 return -LOS_NOK;
83 }
84
85 part = los_part_find(node);//通过索引节点找到分区信息
86 VnodeDrop();
87 show_part(part);
88
89 return LOS_OK;
90}
VOID show_part(los_part *part)
Print partition information.
Definition: disk.c:1810
los_part * los_part_find(struct Vnode *blkDriver)
Find disk partition.
Definition: disk.c:1682
char CHAR
Definition: los_typedef.h:63
vnode并不包含文件名,因为 vnode和文件名是 1:N 的关系
Definition: vnode.h:164
int VnodeDrop(void)
归还锁
Definition: vnode.c:292
int VnodeHold(void)
拿锁,封装互斥量
Definition: vnode.c:283
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags)
通过路径查询vnode节点
Definition: vnode.c:491
函数调用图:

◆ SHELLCMD_ENTRY()

SHELLCMD_ENTRY ( partinfo_shellcmd  ,
CMD_TYPE_EX  ,
"partinfo"  ,
XARGS  ,
(CmdCallBackFunc osShellCmdPartInfo 
)