summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdike <jdike>2003-01-18 16:26:23 +0000
committerjdike <jdike>2003-01-18 16:26:23 +0000
commit1da2b82c9368f98cb41fce3eae842045e6a8edfd (patch)
tree9a8196e34390367afdf3368f0b5fe6fcf81e9973
parent44d6427d5e62381d9ef4325f95edba32c04686da (diff)
downloaduml-history-1da2b82c9368f98cb41fce3eae842045e6a8edfd.tar.gz
Added FD_CLOEXEC support to os open.
-rw-r--r--arch/um/include/os.h10
-rw-r--r--arch/um/os-Linux/file.c12
2 files changed, 19 insertions, 3 deletions
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 0e6bd08..d5fcd8f 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -25,9 +25,11 @@ struct openflags {
unsigned int t : 1; /* O_TRUNC */
unsigned int a : 1; /* O_APPEND */
unsigned int e : 1; /* O_EXCL */
+ unsigned int cl : 1; /* FD_CLOEXEC */
};
-#define OPENFLAGS() ((struct openflags) { r : 0, w : 0, c : 0, s : 0 })
+#define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \
+ .t = 0, .a = 0, .e = 0, .cl = 0 })
static inline struct openflags of_read(struct openflags flags)
{
@@ -82,6 +84,12 @@ static inline struct openflags of_excl(struct openflags flags)
flags.e = 1;
return(flags);
}
+
+static inline struct openflags of_cloexec(struct openflags flags)
+{
+ flags.cl = 1;
+ return(flags);
+}
extern int os_seek_file(int fd, __u64 offset);
extern int os_open_file(char *file, struct openflags flags, int mode);
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index 9f0cfed..3b4c7d5 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -28,8 +28,8 @@ int os_file_type(char *file)
else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK);
else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV);
else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV);
- else if(S_ISFIFO(buf.st_mode))return(OS_TYPE_FIFO);
- else if(S_ISSOCK(buf.st_mode))return(OS_TYPE_SOCK);
+ else if(S_ISFIFO(buf.st_mode)) return(OS_TYPE_FIFO);
+ else if(S_ISSOCK(buf.st_mode)) return(OS_TYPE_SOCK);
else return(OS_TYPE_FILE);
}
@@ -64,6 +64,14 @@ int os_open_file(char *file, struct openflags flags, int mode)
fd = open64(file, f, mode);
if(fd < 0) return(-errno);
+
+ if(flags.cl){
+ if(fcntl(fd, F_SETFD, 1)){
+ close(fd);
+ return(-errno);
+ }
+ }
+
return(fd);
}