mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 11:20:04 +02:00
check if drive is a normal file or special block file
This commit is contained in:
parent
4a663e9e50
commit
3796182eb1
@ -274,7 +274,8 @@ int allowUpdate(char *mess, char *functionType) {
|
|||||||
getKernelVersion(retvals);
|
getKernelVersion(retvals);
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
snprintf(mess, MAX_STR_LENGTH,
|
||||||
"Could not update %s. Kernel version %s is too old to "
|
"Could not update %s. Kernel version %s is too old to "
|
||||||
"update the Amd flash/ root directory. Most likely, blackfin needs rescue or replacement. Please contact us.\n",
|
"update the Amd flash/ root directory. Most likely, blackfin "
|
||||||
|
"needs rescue or replacement. Please contact us.\n",
|
||||||
functionType, retvals);
|
functionType, retvals);
|
||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -447,6 +448,30 @@ int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd) {
|
|||||||
}
|
}
|
||||||
LOG(logDEBUG1, ("Temp file ready for reading\n"));
|
LOG(logDEBUG1, ("Temp file ready for reading\n"));
|
||||||
|
|
||||||
|
#ifndef VIRTUAL
|
||||||
|
// check if its a normal file or special file
|
||||||
|
structure 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)) {
|
||||||
|
sprintf(mess,
|
||||||
|
"Could not %s. The flash drive found is a normal file. To "
|
||||||
|
"delete this file, create the flash drive and proceed with "
|
||||||
|
"programming, re-run the programming command with parameter "
|
||||||
|
"'--force-delete-normal-file'\n",
|
||||||
|
messageType);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// open flash drive for writing
|
// open flash drive for writing
|
||||||
*flashfd = fopen(flashDriveName, "w");
|
*flashfd = fopen(flashDriveName, "w");
|
||||||
if (*flashfd == NULL) {
|
if (*flashfd == NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user