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

浏览源代码.

函数

int osShellCmdFormat (int argc, char **argv)
 
 SHELLCMD_ENTRY (format_shellcmd, CMD_TYPE_EX, "format", XARGS,(CmdCallBackFunc) osShellCmdFormat)
 

函数说明

◆ osShellCmdFormat()

int osShellCmdFormat ( int  argc,
char **  argv 
)

在文件 fat_shellcmd.c42 行定义.

43{
44 if (argc < 3) { /* 3, at least 3 params for this shell command. */
45 perror("format error");
46 PRINTK("Usage :\n");
47 PRINTK(" format <dev_vnodename> <sectors> <option> <label>\n");
48 PRINTK(" dev_vnodename : the name of dev\n");
49 PRINTK(" sectors : Size of allocation unit in unit of byte or sector, ");
50 PRINTK("0 instead of default size\n");
51 PRINTK(" options : Index of filesystem. 1 for FAT filesystem, ");
52 PRINTK("2 for FAT32 filesystem, 7 for any, 8 for erase\n");
53 PRINTK(" label : The volume of device. It will be emptyed when this parameter is null\n");
54 PRINTK("Example:\n");
55 PRINTK(" format /dev/mmcblk0 128 2\n");
56
57 set_errno(EINVAL);
58 return 0;
59 }
60
61 if (argc == 4) { /* 4, if the params count is equal to 4, then do this. */
62 /* 3, get the param and check. */
63 if (strncmp(argv[3], "NULL", strlen(argv[3])) == 0 || strncmp(argv[3], "null", strlen(argv[3])) == 0) {
64 set_label(NULL);
65 } else {
66 set_label(argv[3]);
67 }
68 }
69 /* 0, 1, 2, get the param and check it. */
70 if (format(argv[0], atoi(argv[1]), atoi(argv[2])) == 0) {
71 PRINTK("format %s Success \n", argv[0]);
72 } else {
73 perror("format error");
74 }
75
76 return 0;
77}
void set_label(const char *name)
Definition: format.c:94
int format(const char *dev, int sectors, int option)
formatting sd card
Definition: format.c:44
函数调用图:

◆ SHELLCMD_ENTRY()

SHELLCMD_ENTRY ( format_shellcmd  ,
CMD_TYPE_EX  ,
"format"  ,
XARGS  ,
(CmdCallBackFunc osShellCmdFormat 
)