]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/um/os-Linux/file.c
uml: miscellaneous code cleanups
[linux-2.6-omap-h63xx.git] / arch / um / os-Linux / file.c
index f834627586272b80c4702b499553ac24c296c9dd..4f547d75b17eae81fd88fece0819957ddaa8e8a4 100644 (file)
@@ -17,9 +17,8 @@
 #include <sys/uio.h>
 #include "os.h"
 #include "user.h"
-#include "kern_util.h"
 
-static void copy_stat(struct uml_stat *dst, struct stat64 *src)
+static void copy_stat(struct uml_stat *dst, const struct stat64 *src)
 {
        *dst = ((struct uml_stat) {
                .ust_dev     = src->st_dev,     /* device */
@@ -168,7 +167,7 @@ int os_file_type(char *file)
        else return OS_TYPE_FILE;
 }
 
-int os_file_mode(char *file, struct openflags *mode_out)
+int os_file_mode(const char *file, struct openflags *mode_out)
 {
        int err;
 
@@ -189,7 +188,7 @@ int os_file_mode(char *file, struct openflags *mode_out)
        return err;
 }
 
-int os_open_file(char *file, struct openflags flags, int mode)
+int os_open_file(const char *file, struct openflags flags, int mode)
 {
        int fd, err, f = 0;
 
@@ -216,7 +215,7 @@ int os_open_file(char *file, struct openflags flags, int mode)
        return fd;
 }
 
-int os_connect_socket(char *name)
+int os_connect_socket(const char *name)
 {
        struct sockaddr_un sock;
        int fd, err;
@@ -277,7 +276,7 @@ int os_write_file(int fd, const void *buf, int len)
        return n;
 }
 
-int os_file_size(char *file, unsigned long long *size_out)
+int os_file_size(const char *file, unsigned long long *size_out)
 {
        struct uml_stat buf;
        int err;
@@ -314,7 +313,7 @@ int os_file_size(char *file, unsigned long long *size_out)
        return 0;
 }
 
-int os_file_modtime(char *file, unsigned long *modtime)
+int os_file_modtime(const char *file, unsigned long *modtime)
 {
        struct uml_stat buf;
        int err;
@@ -329,19 +328,6 @@ int os_file_modtime(char *file, unsigned long *modtime)
        return 0;
 }
 
-int os_get_exec_close(int fd, int *close_on_exec)
-{
-       int ret;
-
-       CATCH_EINTR(ret = fcntl(fd, F_GETFD));
-
-       if(ret < 0)
-               return -errno;
-
-       *close_on_exec = (ret & FD_CLOEXEC) ? 1 : 0;
-       return ret;
-}
-
 int os_set_exec_close(int fd)
 {
        int err;
@@ -381,30 +367,27 @@ int os_pipe(int *fds, int stream, int close_on_exec)
        return err;
 }
 
-int os_set_fd_async(int fd, int owner)
+int os_set_fd_async(int fd)
 {
-       int err;
+       int err, flags;
+
+       flags = fcntl(fd, F_GETFL);
+       if (flags < 0)
+               return -errno;
 
-       /* XXX This should do F_GETFL first */
-       if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){
+       flags |= O_ASYNC | O_NONBLOCK;
+       if (fcntl(fd, F_SETFL, flags) < 0) {
                err = -errno;
                printk("os_set_fd_async : failed to set O_ASYNC and "
                       "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno);
                return err;
        }
-#ifdef notdef
-       if(fcntl(fd, F_SETFD, 1) < 0){
-               printk("os_set_fd_async : Setting FD_CLOEXEC failed, "
-                      "errno = %d\n", errno);
-       }
-#endif
 
-       if((fcntl(fd, F_SETSIG, SIGIO) < 0) ||
-          (fcntl(fd, F_SETOWN, owner) < 0)){
+       if ((fcntl(fd, F_SETSIG, SIGIO) < 0) ||
+           (fcntl(fd, F_SETOWN, os_getpid()) < 0)) {
                err = -errno;
                printk("os_set_fd_async : Failed to fcntl F_SETOWN "
-                      "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd,
-                      owner, errno);
+                      "(or F_SETSIG) fd %d, errno = %d\n", fd, errno);
                return err;
        }
 
@@ -514,7 +497,7 @@ int os_rcv_fd(int fd, int *helper_pid_out)
        return new;
 }
 
-int os_create_unix_socket(char *file, int len, int close_on_exec)
+int os_create_unix_socket(const char *file, int len, int close_on_exec)
 {
        struct sockaddr_un addr;
        int sock, err;