aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-02-01 15:11:47 +0000
committerCorinna Vinschen <corinna@vinschen.de>2005-02-01 15:11:47 +0000
commite8309efda5499f88eb950ff652acdd3a6b07d678 (patch)
treef1799405b3d3a841422f773c89c9d45538d83392 /winsup
parentd93998b17a4c7f07925ecdd48a9474864ba47aea (diff)
downloadnewlib-e8309efda5499f88eb950ff652acdd3a6b07d678.zip
newlib-e8309efda5499f88eb950ff652acdd3a6b07d678.tar.gz
newlib-e8309efda5499f88eb950ff652acdd3a6b07d678.tar.bz2
* fhandler.cc (fhandler_base::get_proc_fd_name): Don't generate
"device:" entry. * fhandler.h (fhandler_socket::open): New method. (fhandler_pipe::open): New method. * fhandler_proc.cc (fhandler_proc::exists): Return -2 in case of /proc/self. * fhandler_process.cc (fhandler_process::exists): Return -2 in case of symlinks, -3 for pipes and -4 for sockets. (fhandler_process::fstat): Handle pipes and sockets. (fhandler_process::open): Handle opening /proc/<pid>/fd. (fhandler_process::fill_filebuf): Generate empty names for non exisiting file descriptors. * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Always generate "socket:[number]" strings as on Linux. (fhandler_socket::open): New method. (fhandler_socket::fstat): Always return socket type. * path.cc (symlink_info::set): Remove unused second parameter. (path_conv::check): Handle pipes and sockets in /proc. Set correct device type for AF_LOCAL sockets. * pinfo.cc (_pinfo::commune_recv): Generate empty names for non exisiting file descriptors. (_pinfo::fd): Ditto. * pipe.cc (fhandler_pipe::open): New method.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog26
-rw-r--r--winsup/cygwin/fhandler.cc3
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/fhandler_proc.cc4
-rw-r--r--winsup/cygwin/fhandler_process.cc32
-rw-r--r--winsup/cygwin/fhandler_socket.cc29
-rw-r--r--winsup/cygwin/path.cc30
-rw-r--r--winsup/cygwin/pinfo.cc4
-rw-r--r--winsup/cygwin/pipe.cc7
9 files changed, 103 insertions, 34 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0a79d6d..465b071 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,29 @@
+2005-02-01 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler.cc (fhandler_base::get_proc_fd_name): Don't generate
+ "device:" entry.
+ * fhandler.h (fhandler_socket::open): New method.
+ (fhandler_pipe::open): New method.
+ * fhandler_proc.cc (fhandler_proc::exists): Return -2 in case of
+ /proc/self.
+ * fhandler_process.cc (fhandler_process::exists): Return -2 in
+ case of symlinks, -3 for pipes and -4 for sockets.
+ (fhandler_process::fstat): Handle pipes and sockets.
+ (fhandler_process::open): Handle opening /proc/<pid>/fd.
+ (fhandler_process::fill_filebuf): Generate empty names for
+ non exisiting file descriptors.
+ * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Always
+ generate "socket:[number]" strings as on Linux.
+ (fhandler_socket::open): New method.
+ (fhandler_socket::fstat): Always return socket type.
+ * path.cc (symlink_info::set): Remove unused second parameter.
+ (path_conv::check): Handle pipes and sockets in /proc.
+ Set correct device type for AF_LOCAL sockets.
+ * pinfo.cc (_pinfo::commune_recv): Generate empty names for
+ non exisiting file descriptors.
+ (_pinfo::fd): Ditto.
+ * pipe.cc (fhandler_pipe::open): New method.
+
2005-01-31 Christopher Faylor <cgf@timesys.com>
* path.h (path_conv::set_name): Declare new function.
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index a58472b..5f60d0e 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -160,8 +160,7 @@ char *fhandler_base::get_proc_fd_name (char *buf)
return strcpy (buf, get_name ());
if (dev ().name)
return strcpy (buf, dev ().name);
- __small_sprintf (buf, "device:[%d:%d]", get_major (), get_minor ());
- return buf;
+ return strcpy (buf, "");
}
/* Detect if we are sitting at EOF for conditions where Windows
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 103404c..4aaafe8 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -377,6 +377,7 @@ class fhandler_socket: public fhandler_base
int getsockname (struct sockaddr *name, int *namelen);
int getpeername (struct sockaddr *name, int *namelen);
+ int open (int flags, mode_t mode = 0);
ssize_t readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
int recvfrom (void *ptr, size_t len, int flags,
struct sockaddr *from, int *fromlen);
@@ -438,6 +439,7 @@ public:
char *get_proc_fd_name (char *buf);
void set_close_on_exec (bool val);
void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3)));
+ int open (int flags, mode_t mode = 0);
int close ();
void create_guard (SECURITY_ATTRIBUTES *sa) {guard = CreateMutex (sa, FALSE, NULL);}
int dup (fhandler_base *child);
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index f47a2fd..95817b9 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -133,7 +133,7 @@ fhandler_proc::get_proc_fhandler (const char *path)
}
/* Returns 0 if path doesn't exist, >0 if path is a directory,
- <0 if path is a file. */
+ -1 if path is a file, -2 if it's a symlink. */
int
fhandler_proc::exists ()
{
@@ -146,7 +146,7 @@ fhandler_proc::exists ()
if (pathmatch (path + 1, proc_listing[i]))
{
fileid = i;
- return (proc_fhandlers[i] == FH_PROC) ? (i == PROC_SELF ? -3 : -1) : 1;
+ return (proc_fhandlers[i] == FH_PROC) ? (i == PROC_SELF ? -2 : -1) : 1;
}
return 0;
}
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index fee6507..565755c 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -92,7 +92,8 @@ static bool get_mem_values (DWORD dwProcessId, unsigned long *vmsize,
unsigned long *vmshare);
/* Returns 0 if path doesn't exist, >0 if path is a directory,
- * -1 if path is a file, -2 if path is a symlink.
+ * -1 if path is a file, -2 if path is a symlink, -3 if path is a pipe,
+ * -4 if path is a socket.
*/
int
fhandler_process::exists ()
@@ -116,6 +117,15 @@ fhandler_process::exists ()
fileid = PROCESS_FD;
if (fill_filebuf ())
return -2;
+ /* Check for nameless device entries. */
+ path = strrchr (path, '/');
+ if (path && *++path)
+ {
+ if (!strncmp (path, "pipe:[", 6))
+ return -3;
+ else if (!strncmp (path, "socket:[", 8))
+ return -4;
+ }
}
return 0;
}
@@ -165,6 +175,16 @@ fhandler_process::fstat (struct __stat64 *buf)
buf->st_gid = p->gid;
buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
return 0;
+ case -3:
+ buf->st_uid = p->uid;
+ buf->st_gid = p->gid;
+ buf->st_mode = S_IFIFO | S_IRUSR | S_IWUSR;
+ return 0;
+ case -4:
+ buf->st_uid = p->uid;
+ buf->st_gid = p->gid;
+ buf->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
+ return 0;
case -1:
default:
buf->st_uid = p->uid;
@@ -269,6 +289,12 @@ fhandler_process::open (int flags, mode_t mode)
goto out;
}
}
+ if (process_file_no == PROCESS_FD)
+ {
+ set_errno (EISDIR);
+ res = 0;
+ goto out;
+ }
if (flags & O_WRONLY)
{
set_errno (EROFS);
@@ -338,8 +364,8 @@ fhandler_process::fill_filebuf ()
filebuf = p->fd (fd, fs);
if (!filebuf || !*filebuf)
{
- filebuf = strdup ("<disconnected>");
- fs = strlen (filebuf) + 1;
+ set_errno (ENOENT);
+ return false;
}
}
filesize = fs;
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index a7e5293..4f55526 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -149,13 +149,17 @@ fhandler_socket::~fhandler_socket ()
char *fhandler_socket::get_proc_fd_name (char *buf)
{
- if (get_sun_path ())
- __small_sprintf (buf, "%s", get_sun_path ());
- else
- __small_sprintf (buf, "socket:[%d]", get_socket ());
+ __small_sprintf (buf, "socket:[%d]", get_socket ());
return buf;
}
+int
+fhandler_socket::open (int flags, mode_t mode)
+{
+ set_errno (ENXIO);
+ return 0;
+}
+
void
fhandler_socket::set_connect_secret ()
{
@@ -385,20 +389,9 @@ fhandler_socket::fstat (struct __stat64 *buf)
int res = fhandler_base::fstat (buf);
if (!res)
{
- if (get_socket_type ()) /* fstat */
- {
- buf->st_dev = 0;
- buf->st_ino = (__ino64_t) ((DWORD) get_handle ());
- buf->st_mode = S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO;
- }
- else
- {
- path_conv spc ("/dev", PC_SYM_NOFOLLOW | PC_NULLEMPTY, NULL);
- buf->st_dev = spc.volser ();
- buf->st_ino = get_namehash ();
- buf->st_mode &= ~S_IRWXO;
- buf->st_rdev = (get_device () << 16) | get_unit ();
- }
+ buf->st_dev = 0;
+ buf->st_ino = (__ino64_t) ((DWORD) get_handle ());
+ buf->st_mode = S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO;
}
return res;
}
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 9705acd..9321a9b 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -95,7 +95,7 @@ struct symlink_info
_minor_t minor;
_mode_t mode;
int check (char *path, const suffix_info *suffixes, unsigned opt);
- int set (char *path, int type);
+ int set (char *path);
bool parse_device (const char *);
bool case_check (char *path);
};
@@ -617,10 +617,10 @@ path_conv::check (const char *src, unsigned opt,
/* FIXME: Calling build_fhandler here is not the right way to handle this. */
fhandler_virtual *fh = (fhandler_virtual *) build_fh_dev (dev, path_copy);
int file_type = fh->exists ();
- if (file_type == -2 || file_type == -3)
+ if (file_type == -2)
{
fh->fill_filebuf ();
- symlen = sym.set (fh->get_filebuf (), file_type);
+ symlen = sym.set (fh->get_filebuf ());
}
delete fh;
switch (file_type)
@@ -632,9 +632,16 @@ path_conv::check (const char *src, unsigned opt,
case -1:
fileattr = 0;
break;
- case -2: /* /proc/<pid>/symlinks */
- case -3: /* /proc/self */
+ case -2: /* /proc/self or /proc/<pid>/symlinks */
goto is_virtual_symlink;
+ case -3: /* /proc/<pid>/fd/pipe:[] */
+ fileattr = 0;
+ dev.parse (FH_PIPE);
+ break;
+ case -4: /* /proc/<pid>/fd/socket:[] */
+ fileattr = 0;
+ dev.parse (FH_TCP);
+ break;
default:
fileattr = INVALID_FILE_ATTRIBUTES;
goto virtual_component_retry;
@@ -678,7 +685,16 @@ is_virtual_symlink:
}
if (sym.pflags & PATH_SOCKET)
- dev.setfs (1);
+ {
+ if (component)
+ {
+ error = ENOTDIR;
+ return;
+ }
+ fileattr = 0;
+ dev.parse (FH_UNIX);
+ goto out;
+ }
if (sym.case_clash)
{
@@ -3142,7 +3158,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
/* "path" is the path in a virtual symlink. Set a symlink_info struct from
that and proceed with further path checking afterwards. */
int
-symlink_info::set (char *path, int type)
+symlink_info::set (char *path)
{
strcpy (contents, path);
pflags = PATH_SYMLINK;
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 1c67f87..69dcb14 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -521,7 +521,7 @@ _pinfo::commune_recv ()
unsigned int n;
cygheap_fdget cfd (fd);
if (cfd < 0)
- n = strlen (strcpy (path, "<disconnected>")) + 1;
+ n = strlen (strcpy (path, "")) + 1;
else
n = strlen (cfd->get_proc_fd_name (path)) + 1;
if (!WriteFile (__tothem, &n, sizeof n, &nr, NULL))
@@ -756,7 +756,7 @@ _pinfo::fd (int fd, size_t &n)
{
cygheap_fdget cfd (fd);
if (cfd < 0)
- s = strdup ("<disconnected>");
+ s = strdup ("");
else
s = cfd->get_proc_fd_name ((char *) malloc (CYG_MAX_PATH + 1));
n = strlen (s) + 1;
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index c2d633a..988ee57 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -35,6 +35,13 @@ fhandler_pipe::fhandler_pipe ()
{
}
+int
+fhandler_pipe::open (int flags, mode_t mode)
+{
+ set_errno (ENXIO);
+ return 0;
+}
+
_off64_t
fhandler_pipe::lseek (_off64_t offset, int whence)
{