summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/devices.h
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-04-01 07:19:52 +0000
committerChristopher Faylor <me@cgf.cx>2012-04-01 07:19:52 +0000
commit727a81f4d93f3715d3692685915f99fca5106a8a (patch)
treeafe283f0a204fab15bf8a3caf96b107f0f177fa4 /winsup/cygwin/devices.h
parente2e887c5aca1e3413b614fb46bb766d6be2283bf (diff)
downloadcygnal-727a81f4d93f3715d3692685915f99fca5106a8a.tar.gz
cygnal-727a81f4d93f3715d3692685915f99fca5106a8a.tar.bz2
cygnal-727a81f4d93f3715d3692685915f99fca5106a8a.zip
* devices.h (device::exists_func): Redefine field.
(device::dev_on_fs): Remove unneeded bit field. Just make a normal boolean. (device::exists): Redefine function. * devices.in: Move previous functions earlier since they are now only defined static. Rename some functions due to an as-yet unresolved bug in gendevices. Rename posix part of internal-only devices with a double-slash. gendevices will eventuall translate that to a ":". (device::parse): Rework to use dev pointer and dev_storage_end. * devices.cc: Regenerate. * gendevices: Translate "// to ": after shilka processing.
Diffstat (limited to 'winsup/cygwin/devices.h')
-rw-r--r--winsup/cygwin/devices.h25
1 files changed, 13 insertions, 12 deletions
diff --git a/winsup/cygwin/devices.h b/winsup/cygwin/devices.h
index d5e20a7e6..d78a2e08d 100644
--- a/winsup/cygwin/devices.h
+++ b/winsup/cygwin/devices.h
@@ -8,8 +8,7 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
-#ifndef _DEVICES_H
-#define _DEVICES_H
+#pragma once
typedef unsigned short _major_t;
typedef unsigned short _minor_t;
@@ -20,6 +19,9 @@ typedef __dev32_t _dev_t;
#define _minor(dev) ((dev) & ((1 << (sizeof (_minor_t) * 8)) - 1))
#define _major(dev) ((dev) >> (sizeof (_major_t) * 8))
+#include <sys/stat.h>
+#include <dirent.h>
+
#define MAX_CONSOLES 63
enum fh_devices
{
@@ -275,9 +277,9 @@ struct device
};
} d;
const char *native;
- bool (device::*exists_func)() const;
- bool dev_on_fs:1;
+ int (*exists_func) (const device&);
_mode_t mode;
+ bool dev_on_fs;
static const device *lookup (const char *, unsigned int = UINT32_MAX);
void parse (const char *);
void parse (_major_t major, _minor_t minor);
@@ -319,13 +321,13 @@ struct device
inline void setfs (bool x) {dev_on_fs = x;}
inline bool isfs () const {return dev_on_fs || d.devn == FH_FS;}
inline bool is_fs_special () const {return dev_on_fs && d.devn != FH_FS;}
-
- bool exists_never () const;
- bool exists_ptys () const;
- bool exists_cons () const;
- bool exists_console () const;
- bool exists_nt_dev () const;
- bool exists () const;
+ inline int exists () const {return exists_func (*this);}
+ unsigned char type () const
+ {
+ if (S_ISBLK (mode))
+ return DT_BLK;
+ return mode >> 12;
+ }
};
extern const device dev_storage[];
@@ -379,4 +381,3 @@ extern const device dev_fs_storage;
|| (((int) n) == FH_CONOUT))
#define istty_slave_dev(n) (device::major (n) == DEV_PTYS_MAJOR)
-#endif /*_DEVICES_H*/