!287 feat(vfs): vfs支持FD_CLOEXEC标记
Merge pull request !287 from MGY917/master
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "asm/page.h"
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "fs/fd_table.h"
|
||||
#include "fs/fs_operation.h"
|
||||
#endif
|
||||
#include "time.h"
|
||||
#include "user_copy.h"
|
||||
@@ -290,7 +291,7 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
|
||||
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
if (OsProcessIsUserMode(processCB)) {
|
||||
delete_files(processCB, processCB->files);
|
||||
delete_files(processCB->files);
|
||||
}
|
||||
processCB->files = NULL;
|
||||
#endif
|
||||
@@ -1306,8 +1307,8 @@ LITE_OS_SEC_TEXT UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR
|
||||
|
||||
LOS_VmSpaceFree(oldSpace);
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
delete_files(OsCurrProcessGet(), (struct files_struct *)oldFiles);
|
||||
alloc_std_fd(OsCurrProcessGet()->files->fdt);
|
||||
CloseOnExec((struct files_struct *)oldFiles);
|
||||
delete_files_snapshot((struct files_struct *)oldFiles);
|
||||
#endif
|
||||
|
||||
OsSwtmrRecycle(processCB->processID);
|
||||
|
||||
@@ -82,7 +82,6 @@ STATIC INT32 OsGetRealPath(const CHAR *fileName, CHAR *buf, UINT32 maxLen)
|
||||
return LOS_OK;
|
||||
|
||||
ERR_FILE:
|
||||
PRINT_ERR("No such file or directory: %s\n", fileName);
|
||||
return -ENOENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "fcntl.h"
|
||||
#include "fs/fd_table.h"
|
||||
#include "fs/file.h"
|
||||
#include "fs/fs_operation.h"
|
||||
#include "los_config.h"
|
||||
#include "los_vm_map.h"
|
||||
#include "los_vm_syscall.h"
|
||||
@@ -56,6 +57,10 @@ static int OsELFOpen(const CHAR *fileName, INT32 oflags)
|
||||
return -EMFILE;
|
||||
}
|
||||
|
||||
if (oflags & O_CLOEXEC) {
|
||||
SetCloexecFlag(procFd);
|
||||
}
|
||||
|
||||
ret = open(fileName, oflags);
|
||||
if (ret < 0) {
|
||||
FreeProcessFd(procFd);
|
||||
@@ -186,7 +191,7 @@ STATIC INT32 OsReadEhdr(const CHAR *fileName, ELFInfo *elfInfo, BOOL isExecFile)
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ret = OsELFOpen(fileName, O_RDONLY | O_EXECVE);
|
||||
ret = OsELFOpen(fileName, O_RDONLY | O_EXECVE | O_CLOEXEC);
|
||||
if (ret < 0) {
|
||||
PRINT_ERR("%s[%d], Failed to open ELF file: %s!\n", __FUNCTION__, __LINE__, fileName);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user