!287 feat(vfs): vfs支持FD_CLOEXEC标记
Merge pull request !287 from MGY917/master
This commit is contained in:
@@ -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