modlib:move get file info logic to modlib
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
18d113e06e
commit
489223f0d5
|
@ -205,6 +205,9 @@ struct mod_loadinfo_s
|
|||
size_t textalign; /* Necessary alignment of .text */
|
||||
size_t dataalign; /* Necessary alignment of .bss/.text */
|
||||
off_t filelen; /* Length of the entire module file */
|
||||
uid_t fileuid; /* Uid of the file system */
|
||||
gid_t filegid; /* Gid of the file system */
|
||||
int filemode; /* Mode of the file system */
|
||||
Elf_Ehdr ehdr; /* Buffered module file header */
|
||||
FAR Elf_Phdr *phdr; /* Buffered module program headers */
|
||||
FAR Elf_Shdr *shdr; /* Buffered module section headers */
|
||||
|
|
|
@ -44,10 +44,10 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: modlib_filelen
|
||||
* Name: modlib_fileinfo
|
||||
*
|
||||
* Description:
|
||||
* Get the size of the ELF file
|
||||
* Get the info of the ELF file
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
|
@ -55,7 +55,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline int modlib_filelen(FAR struct mod_loadinfo_s *loadinfo)
|
||||
static inline int modlib_fileinfo(FAR struct mod_loadinfo_s *loadinfo)
|
||||
{
|
||||
struct stat buf;
|
||||
int ret;
|
||||
|
@ -78,9 +78,12 @@ static inline int modlib_filelen(FAR struct mod_loadinfo_s *loadinfo)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Return the size of the file in the loadinfo structure */
|
||||
/* Return some stats info of the file in the loadinfo structure */
|
||||
|
||||
loadinfo->filelen = buf.st_size;
|
||||
loadinfo->filelen = buf.st_size;
|
||||
loadinfo->fileuid = buf.st_uid;
|
||||
loadinfo->filegid = buf.st_gid;
|
||||
loadinfo->filemode = buf.st_mode;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -122,12 +125,12 @@ int modlib_initialize(FAR const char *filename,
|
|||
return -errval;
|
||||
}
|
||||
|
||||
/* Get the length of the file. */
|
||||
/* Get some stats info of the file. */
|
||||
|
||||
ret = modlib_filelen(loadinfo);
|
||||
ret = modlib_fileinfo(loadinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: modlib_filelen failed: %d\n", ret);
|
||||
berr("ERROR: modlib_fileinfo failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue