aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler/zero.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2022-08-04 16:58:50 +0200
committerCorinna Vinschen <corinna@vinschen.de>2022-08-05 12:02:11 +0200
commit007e23d6390af11582e55453269b7a51c723d2dd (patch)
tree8e8cff3ca23f5e56d9766a5ee6c6abb366611b07 /winsup/cygwin/fhandler/zero.cc
parent1e428bee1c5ef7c76ba4e46e6693b913edc9bbf3 (diff)
downloadnewlib-007e23d6390af11582e55453269b7a51c723d2dd.zip
newlib-007e23d6390af11582e55453269b7a51c723d2dd.tar.gz
newlib-007e23d6390af11582e55453269b7a51c723d2dd.tar.bz2
Cygwin: Reorganize cygwin source dir
Create subdirs and move files accordingly: - DevDocs: doc files - fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc - local_includes: local include files - scripts: scripts called during build - sec: security sources Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/fhandler/zero.cc')
-rw-r--r--winsup/cygwin/fhandler/zero.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler/zero.cc b/winsup/cygwin/fhandler/zero.cc
new file mode 100644
index 0000000..9d8fe00
--- /dev/null
+++ b/winsup/cygwin/fhandler/zero.cc
@@ -0,0 +1,37 @@
+/* fhandler_dev_zero.cc: code to access /dev/zero
+
+ Written by DJ Delorie (dj@cygnus.com)
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#include "winsup.h"
+#include "security.h"
+#include "cygerrno.h"
+#include "path.h"
+#include "fhandler.h"
+
+fhandler_dev_zero::fhandler_dev_zero ()
+ : fhandler_base ()
+{
+}
+
+ssize_t
+fhandler_dev_zero::write (const void *, size_t len)
+{
+ if (get_device () == FH_FULL)
+ {
+ set_errno (ENOSPC);
+ return -1;
+ }
+ return len;
+}
+
+void
+fhandler_dev_zero::read (void *ptr, size_t& len)
+{
+ memset (ptr, 0, len);
+}