Skip to content

Commit e930476

Browse files
gneworldxiaoxiang781216
authored andcommitted
enable O_CLOEXEC explicit
Signed-off-by: wanggang26 <[email protected]>
1 parent 2d817de commit e930476

File tree

25 files changed

+41
-35
lines changed

25 files changed

+41
-35
lines changed

arch/arm/src/cxd56xx/cxd56_gnss.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ static int cxd56_gnss_save_backup_data(struct file *filep,
914914
}
915915

916916
n = file_open(&file, CONFIG_CXD56_GNSS_BACKUP_FILENAME,
917-
O_WRONLY | O_CREAT | O_TRUNC);
917+
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC);
918918
if (n < 0)
919919
{
920920
kmm_free(buf);
@@ -2333,7 +2333,8 @@ static void cxd56_gnss_read_backup_file(int *retval)
23332333
goto err;
23342334
}
23352335

2336-
ret = file_open(&file, CONFIG_CXD56_GNSS_BACKUP_FILENAME, O_RDONLY);
2336+
ret = file_open(&file, CONFIG_CXD56_GNSS_BACKUP_FILENAME,
2337+
O_RDONLY | O_CLOEXEC);
23372338
if (ret < 0)
23382339
{
23392340
kmm_free(buf);
@@ -2489,7 +2490,8 @@ static void cxd56_gnss_default_sighandler(uint32_t data, void *userdata)
24892490
file_close(&priv->cepfp);
24902491
}
24912492

2492-
file_open(&priv->cepfp, CONFIG_CXD56_GNSS_CEP_FILENAME, O_RDONLY);
2493+
file_open(&priv->cepfp, CONFIG_CXD56_GNSS_CEP_FILENAME,
2494+
O_RDONLY | O_CLOEXEC);
24932495
return;
24942496

24952497
case CXD56_GNSS_NOTIFY_TYPE_REQCEPCLOSE:

arch/arm/src/lc823450/lc823450_ipl2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int install_recovery(const char *srcpath)
187187
return -1;
188188
}
189189

190-
ret = file_open(&rfile, srcpath, O_RDONLY, 0444);
190+
ret = file_open(&rfile, srcpath, O_RDONLY | O_CLOEXEC, 0444);
191191

192192
if (file_read(&rfile, &upg_image, sizeof(upg_image)) != sizeof(upg_image))
193193
{

arch/arm/src/rtl8720c/ameba_hci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static int hci_open(struct file *filep)
389389
hci_dev_t *dev = inode->i_private;
390390
int ret;
391391
ret = file_open(&dev->filep,
392-
CONFIG_AMEBA_HCI_DEV_NAME, O_RDWR);
392+
CONFIG_AMEBA_HCI_DEV_NAME, O_RDWR | O_CLOEXEC);
393393
if (ret < 0)
394394
{
395395
return ret;

binfmt/libelf/libelf_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
127127

128128
/* Open the binary file for reading (only) */
129129

130-
ret = file_open(&loadinfo->file, filename, O_RDONLY);
130+
ret = file_open(&loadinfo->file, filename, O_RDONLY | O_CLOEXEC);
131131
if (ret < 0)
132132
{
133133
berr("Failed to open ELF binary %s: %d\n", filename, ret);

binfmt/libnxflat/libnxflat_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
9696

9797
/* Open the binary file */
9898

99-
ret = file_open(&loadinfo->file, filename, O_RDONLY);
99+
ret = file_open(&loadinfo->file, filename, O_RDONLY | O_CLOEXEC);
100100
if (ret < 0)
101101
{
102102
berr("ERROR: Failed to open NXFLAT binary %s: %d\n", filename, ret);

drivers/bch/bchdev_unregister.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int bchdev_unregister(FAR const char *chardev)
7070

7171
/* Open the character driver associated with chardev */
7272

73-
ret = file_open(&filestruct, chardev, O_RDONLY);
73+
ret = file_open(&filestruct, chardev, O_RDONLY | O_CLOEXEC);
7474
if (ret < 0)
7575
{
7676
_err("ERROR: Failed to open %s: %d\n", chardev, ret);

drivers/loop/losetup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ int losetup(FAR const char *devname, FAR const char *filename,
372372
ret = -ENOSYS;
373373
if (!readonly)
374374
{
375-
ret = file_open(&dev->devfile, filename, O_RDWR);
375+
ret = file_open(&dev->devfile, filename, O_RDWR | O_CLOEXEC);
376376
}
377377

378378
if (ret >= 0)
@@ -383,7 +383,7 @@ int losetup(FAR const char *devname, FAR const char *filename,
383383
{
384384
/* If that fails, then try to open the device read-only */
385385

386-
ret = file_open(&dev->devfile, filename, O_RDONLY);
386+
ret = file_open(&dev->devfile, filename, O_RDONLY | O_CLOEXEC);
387387
if (ret < 0)
388388
{
389389
ferr("ERROR: Failed to open %s: %d\n", filename, ret);

drivers/mtd/filemtd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, size_t offset,
749749

750750
/* Set the file open mode. */
751751

752-
mode = O_RDOK | O_WROK;
752+
mode = O_RDOK | O_WROK | O_CLOEXEC;
753753

754754
/* Try to open the file. NOTE that block devices will use a character
755755
* driver proxy.

drivers/mtd/mtd_config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <stdbool.h>
3838
#include <string.h>
3939
#include <poll.h>
40+
#include <fcntl.h>
4041
#include <assert.h>
4142
#include <errno.h>
4243
#include <debug.h>
@@ -1801,7 +1802,7 @@ int mtdconfig_unregister(void)
18011802
FAR struct inode *inode;
18021803
FAR struct mtdconfig_struct_s *dev;
18031804

1804-
ret = file_open(&file, "/dev/config", 0);
1805+
ret = file_open(&file, "/dev/config", O_CLOEXEC);
18051806
if (ret < 0)
18061807
{
18071808
ferr("ERROR: open /dev/config failed: %d\n", ret);

drivers/mtd/mtd_config_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,7 @@ int mtdconfig_unregister_by_path(FAR const char *path)
20812081
FAR struct inode *inode;
20822082
FAR struct nvs_fs *fs;
20832083

2084-
ret = file_open(&file, path, 0);
2084+
ret = file_open(&file, path, O_CLOEXEC);
20852085
if (ret < 0)
20862086
{
20872087
ferr("ERROR: open file %s err: %d\n", path, ret);

0 commit comments

Comments
 (0)