test if special file when updating kernel(solution: reboot only), --force-delete-normal-file used to force delete bfin fpga drive if normal file and create proper device tree

This commit is contained in:
2022-03-22 16:44:12 +01:00
parent f538b8b10b
commit 0f4bcf3a9d
11 changed files with 194 additions and 57 deletions

View File

@ -146,6 +146,30 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
}
int openFileForFlash(char *mess, FILE **flashfd) {
#ifndef VIRTUAL
// check if its a normal file or special file
struct stat buf;
if (stat(flashDriveName, &buf) == -1) {
sprintf(mess,
"Could not %s. Unable to validate if flash drive found is a "
"special file\n",
messageType);
LOG(logERROR, (mess));
return FAIL;
}
// non zero = block special file
if (S_ISBLK(buf.st_mode)) {
// memory is not permanent
sprintf(mess,
"Could not %s. The flash drive found is a normal file. "
"Reboot board using 'rebootcontroller' command to load "
"proper device tree\n",
messageType);
LOG(logERROR, (mess));
return FAIL;
}
#endif
*flashfd = fopen(flashDriveName, "w");
if (*flashfd == NULL) {
sprintf(mess,