Can you explain to me how I can do a mini program that does a system call in C in order to format the disk and create a new partition?
O/S is LynxOS.
Can you explain to me how I can do a mini program that does a system call in C in order to format the disk and create a new partition?
O/S is LynxOS.
Which commands would you execute at the shell?
Superficially, you could use some variant on this:
#include <stdlib.h>
static const char *cmds[] =
{
"command 1 with options",
"command 2 with different options",
0,
};
int main(void)
{
int i;
for (i = 0; cmds[i] != 0; i++)
if (system(cmds[i]) != 0)
exit(EXIT_FAILURE);
return(EXIT_SUCCESS);
}
I assume that the commands will provide appropriate diagnosis of any problems. If you need to control the arguments, then you have more work to do.
The main caveat is "is this the disk that the o/s is running on", because if so, the chances are that the formatting of that disk will stop the programs from running successfully.