diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-09-08 09:10:21 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-09-08 09:10:21 +0000 |
commit | f99de2b3d20e575a2c479f4d445a2c2efa75283d (patch) | |
tree | fc05d2ac2196fff91ed15691ccd06ffaaf64b259 /winsup | |
parent | fa3ab15b1c94c8c1532cfd6fecba482b39f96074 (diff) | |
download | newlib-f99de2b3d20e575a2c479f4d445a2c2efa75283d.zip newlib-f99de2b3d20e575a2c479f4d445a2c2efa75283d.tar.gz newlib-f99de2b3d20e575a2c479f4d445a2c2efa75283d.tar.bz2 |
* fhandler_procsys.cc (fhandler_procsys::open): Simplify by just
calling fhandler_base::open.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_procsys.cc | 80 |
2 files changed, 24 insertions, 61 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 07c9a75..65c0f03 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,6 +1,7 @@ -2010-09-07 Christopher Faylor <me+cygwin@cgf.cx> +2010-09-08 Corinna Vinschen <corinna@vinschen.de> - * + * fhandler_procsys.cc (fhandler_procsys::open): Simplify by just + calling fhandler_base::open. 2010-09-06 Corinna Vinschen <corinna@vinschen.de> diff --git a/winsup/cygwin/fhandler_procsys.cc b/winsup/cygwin/fhandler_procsys.cc index aa0b6b6..317e6f7 100644 --- a/winsup/cygwin/fhandler_procsys.cc +++ b/winsup/cygwin/fhandler_procsys.cc @@ -339,70 +339,32 @@ fhandler_procsys::write (const void *ptr, size_t len) int fhandler_procsys::open (int flags, mode_t mode) { - UNICODE_STRING path; - OBJECT_ATTRIBUTES attr; - IO_STATUS_BLOCK io; - NTSTATUS status; - HANDLE h; - ULONG access; - ULONG options = FILE_OPEN_FOR_BACKUP_INTENT; - + int res = 0; - int res = fhandler_virtual::open (flags, mode); - if (!res) - goto out; - - if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) || (flags & O_TRUNC)) - { - set_errno (EINVAL); - res = 0; - goto out; - } - mk_unicode_path (&path); - InitializeObjectAttributes (&attr, &path, OBJ_INHERIT | OBJ_CASE_INSENSITIVE, - NULL, NULL); - switch (exists ()) + if ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) + set_errno (EINVAL); + else { - case virt_directory: - case virt_rootdir: - if ((flags & O_ACCMODE) != O_RDONLY) + switch (exists ()) { - set_errno (EISDIR); - res = 0; - goto out; + case virt_directory: + case virt_rootdir: + if ((flags & O_ACCMODE) != O_RDONLY) + set_errno (EISDIR); + else + { + nohandle (true); + res = 1; + } + break; + case virt_none: + set_errno (ENOENT); + break; + default: + res = fhandler_base::open (flags, mode); + break; } - nohandle (true); - res = 1; - goto out; - default: - break; - } - if ((flags & O_ACCMODE) == O_RDONLY) - access = GENERIC_READ; - else if ((flags & O_ACCMODE) == O_WRONLY) - access = GENERIC_WRITE | READ_CONTROL | FILE_READ_ATTRIBUTES; - else - access = GENERIC_READ | GENERIC_WRITE; - if (flags & O_SYNC) - options |= FILE_WRITE_THROUGH; - if (flags & O_DIRECT) - options |= FILE_NO_INTERMEDIATE_BUFFERING; - if (!(flags & O_NONBLOCK)) - { - access |= SYNCHRONIZE; - options |= FILE_SYNCHRONOUS_IO_NONALERT; - } - status = NtOpenFile (&h, access, &attr, &io, FILE_SHARE_VALID_FLAGS, options); - if (!NT_SUCCESS (status)) - { - __seterrno_from_nt_status (status); - res = 0; - goto out; } - set_io_handle (h); - set_open_status (); - res = 1; -out: syscall_printf ("%d = fhandler_procsys::open (%p, %d)", res, flags, mode); return res; } |