c - how to Find the Mount Path of Pendrive in better way? -
I have a requirement that my embedded system is included in the program which is initially a pendrive in pendrive and specific directory Looks for If the directory is considered as a bootable device. Consider
below code:
uint8 Chek_ BB_rootfs_Availability () {uint8 b_flag = 0x00; Dw_PkgAvailFlag | = BB_PKG_AVAIL_MASK; If (! (System ( "ls / media1 / sda / UPGRADE_FILES / BB /"))) {path_argv [0] = "/media1/sda/UPGRADE_FILES/BB/rootfs.ubifs"; } And if (! (System ("ls / media1 / sda1 / UPGRADE_FILES / bb /"))) {path_argv [0] = "/media1/sda/UPGRADE_FILES/BB/rootfs.ubifs"; } Else if (! (System ( "ls / media2 / sda / UPGRADE_FILES / BB /"))) {path_argv [0] = "/media2/sda/UPGRADE_FILES/BB/rootfs.ubifs"; } And if (! (System ("ls / media2 / sda1 / UPGRADE_FILES / bb /"))) {path_argv [0] = "/media2/sda1/UPGRADE_FILES/BB/rootfs.ubifs"; } And if (! (System ("ls / media / sda / UPGRADE_FILES / bb /"))} {path_argv [0] = "/ media / sda / urpidihii / bb / roff.a.f.} and if (! (System ("ls / media / sda1 / UPGRADE_FILES / bb /"))) {path_argv [0] = "/ media / sda / urpdaiii / bb / roffaff.f.f } Other {/ * Normal Boot * / dw_PkgAvailFlag & amp; = ~ (BB_PKG_AVAIL_MASK); B_flag = 0x01; } Return b_flag; } If the root is available I call a script which upgrades.
Is this ... if there is a better condition than using any condition and system code.
In addition to this, I am facing another problem when I am using the system call then I have an argument for the system call Can not pass char * path_argv [0] as. Again I have to do this system ("/ media / sda1 / UPGRADE_FILES / BB / UPGRADEBB_File.sh '/media/sda1/UPGRADE_FILES/BB/rootfs.ubifs'"); Any way I can pass the pointer without using the execv call because I do not have to make any new process.
You can view the system call. This allows you to test for the existence of a certain file or directory.
You can use "print" in "string".
Four CMDs [1024] = ""; / * Ensure that this buffer is large enough * / sprint (CMD, "/ media / sda1 / urpardaaiiIls / bb / uparab file.sh '% s'', path_ARGR [0]); Int Results = System (CMD);
Comments
Post a Comment