mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
binfmt: remove file_ioctl and get filename by strrchr
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
+5
-13
@@ -78,6 +78,7 @@ static int builtin_loadbinary(FAR struct binary_s *binp,
|
|||||||
int nexports)
|
int nexports)
|
||||||
{
|
{
|
||||||
FAR const struct builtin_s *builtin;
|
FAR const struct builtin_s *builtin;
|
||||||
|
FAR char *name;
|
||||||
struct file file;
|
struct file file;
|
||||||
int index;
|
int index;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -93,22 +94,13 @@ static int builtin_loadbinary(FAR struct binary_s *binp,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this file is a BINFS file system, then we can recover the name of
|
name = strrchr(filename, '/');
|
||||||
* the file using the FIOC_FILENAME ioctl() call.
|
if (name != NULL)
|
||||||
*/
|
|
||||||
|
|
||||||
ret = file_ioctl(&file, FIOC_FILENAME,
|
|
||||||
(unsigned long)((uintptr_t)&filename));
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
{
|
||||||
berr("ERROR: FIOC_FILENAME ioctl failed: %d\n", ret);
|
filename = name + 1;
|
||||||
file_close(&file);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Other file systems may also support FIOC_FILENAME, so the real proof
|
/* Looking up the index to this name in g_builtins[] */
|
||||||
* is that we can look up the index to this name in g_builtins[].
|
|
||||||
*/
|
|
||||||
|
|
||||||
index = builtin_isavail(filename);
|
index = builtin_isavail(filename);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user