]> sourceware.org Git - newlib-cygwin.git/commitdiff
* fhandler_procnet.cc: Reorganize global procnet content data into a
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 20 Jan 2009 18:04:32 +0000 (18:04 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 20 Jan 2009 18:04:32 +0000 (18:04 +0000)
new struct virt_tab_t.  Accommodate throughout.

* fhandler.h: Fix copyright dates.
* fhandler_process.cc: Ditto.
* fhandler_registry.cc: Ditto.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_process.cc
winsup/cygwin/fhandler_procnet.cc
winsup/cygwin/fhandler_registry.cc

index dd9e45fd334c5695e2ff689151aa56cd6fe88827..36939198a0c2d38a96c2f694168c1fca1f92bbbc 100644 (file)
@@ -1,3 +1,12 @@
+2009-01-20  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_procnet.cc: Reorganize global procnet content data into a
+       new struct virt_tab_t.  Accommodate throughout.
+
+       * fhandler.h: Fix copyright dates.
+       * fhandler_process.cc: Ditto.
+       * fhandler_registry.cc: Ditto.
+
 2009-01-20  Corinna Vinschen  <corinna@vinschen.de>
 
        * devices.h (FH_PROCESSFD): New device type.
index 66f90a058afdafe0a562dbb3833d93af06a2df37..b737c481b4a7512fe9a705322dd5106cfdbbed9f 100644 (file)
@@ -1,7 +1,7 @@
 /* fhandler.h
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008 Red Hat, Inc.
+   2005, 2006, 2007, 2008, 2009 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index 1f0198a822eed459def4ed2b53d77342d2271f9b..710fbe72d17e0349be9baadbcf4d156f5c501fa4 100644 (file)
@@ -1,6 +1,6 @@
 /* fhandler_process.cc: fhandler for /proc/<pid> virtual filesystem
 
-   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.
+   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index e151555d49f36cf98898f192ce1c3b51a6de506d..3cf29dd6c06e3a43f6ceafc5c2156dabfa703da5 100644 (file)
@@ -1,6 +1,6 @@
 /* fhandler_procnet.cc: fhandler for /proc/net virtual filesystem
 
-   Copyright 2007 Red Hat, Inc.
+   Copyright 2007, 2008, 2009 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -15,6 +15,7 @@ details. */
 #include "security.h"
 #include "path.h"
 #include "fhandler.h"
+#include "fhandler_virtual.h"
 #include "dtable.h"
 #include "cygheap.h"
 
@@ -34,20 +35,18 @@ extern "C" int ip_addr_prefix (PIP_ADAPTER_UNICAST_ADDRESS pua,
                               PIP_ADAPTER_PREFIX pap);
 bool get_adapters_addresses (PIP_ADAPTER_ADDRESSES *pa0, ULONG family);
 
-static const int PROCNET_IFINET6 = 2;
+static _off64_t format_procnet_ifinet6 (void *, char *&);
 
-static const char * const process_listing[] =
+static const virt_tab_t procnet_tab[] =
 {
-  ".",
-  "..",
-  "if_inet6",
-  NULL
+  { ".",        FH_PROCNET, virt_directory, NULL },
+  { "..",       FH_PROCNET, virt_directory, NULL },
+  { "if_inet6", FH_PROCNET, virt_file,      format_procnet_ifinet6 },
+  { NULL,       0,          virt_none,      NULL }
 };
 
-static const int PROCESS_LINK_COUNT =
-  (sizeof (process_listing) / sizeof (const char *)) - 1;
-
-static _off64_t format_procnet_ifinet6 (char *&filebuf);
+static const int PROCNET_LINK_COUNT =
+  (sizeof (procnet_tab) / sizeof (virt_tab_t)) - 1;
 
 /* 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, -3 if path is a pipe,
@@ -64,19 +63,19 @@ fhandler_procnet::exists ()
   if (*path == 0)
     return 1;
 
-  for (int i = 0; process_listing[i]; i++)
-    if (!strcmp (path + 1, process_listing[i]))
+  for (int i = 0; procnet_tab[i].name; i++)
+    if (!strcmp (path + 1, procnet_tab[i].name))
       {
-       if (i == PROCNET_IFINET6)
+       if (procnet_tab[i].type == virt_file)
          {
            if (!wincap.has_gaa_prefixes ()
                || !get_adapters_addresses (NULL, AF_INET6))
-             return 0;
+             return virt_none;
          }
        fileid = i;
-       return -1;
+       return procnet_tab[i].type;
       }
-  return 0;
+  return virt_none;
 }
 
 fhandler_procnet::fhandler_procnet ():
@@ -92,15 +91,15 @@ fhandler_procnet::fstat (struct __stat64 *buf)
   int file_type = exists ();
   switch (file_type)
     {
-    case 0:
+    case virt_none:
       set_errno (ENOENT);
       return -1;
-    case 1:
-    case 2:
+    case virt_directory:
+    case virt_rootdir:
       buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
       buf->st_nlink = 2;
       return 0;
-    case -1:
+    case virt_file:
     default:
       buf->st_mode |= S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
       return 0;
@@ -111,15 +110,15 @@ int
 fhandler_procnet::readdir (DIR *dir, dirent *de)
 {
   int res = ENMFILE;
-  if (dir->__d_position >= PROCESS_LINK_COUNT)
+  if (dir->__d_position >= PROCNET_LINK_COUNT)
     goto out;
-  if (dir->__d_position == PROCNET_IFINET6)
+  if (procnet_tab[dir->__d_position].type == virt_file)
     {
       if (!wincap.has_gaa_prefixes ()
          || !get_adapters_addresses (NULL, AF_INET6))
        goto out;
     }
-  strcpy (de->d_name, process_listing[dir->__d_position++]);
+  strcpy (de->d_name, procnet_tab[dir->__d_position++].name);
   dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot;
   res = 0;
 out:
@@ -165,10 +164,10 @@ fhandler_procnet::open (int flags, mode_t mode)
     }
 
   process_file_no = -1;
-  for (int i = 0; process_listing[i]; i++)
+  for (int i = 0; procnet_tab[i].name; i++)
     {
-      if (path_prefix_p (process_listing[i], path + 1,
-                        strlen (process_listing[i]), false))
+      if (path_prefix_p (procnet_tab[i].name, path + 1,
+                        strlen (procnet_tab[i].name), false))
        process_file_no = i;
     }
   if (process_file_no == -1)
@@ -217,16 +216,12 @@ out:
 bool
 fhandler_procnet::fill_filebuf ()
 {
-  switch (fileid)
+  if (procnet_tab[fileid].format_func)
     {
-    case PROCNET_IFINET6:
-      {
-       filesize = format_procnet_ifinet6 (filebuf);
-       break;
-      }
+      filesize = procnet_tab[fileid].format_func (NULL, filebuf);
+      return true;
     }
-
-  return true;
+  return false;
 }
 
 /* Return the same scope values as Linux. */
@@ -255,7 +250,7 @@ static unsigned int dad_to_flags[] =
 };
 
 static _off64_t
-format_procnet_ifinet6 (char *&filebuf)
+format_procnet_ifinet6 (void *, char *&filebuf)
 {
   PIP_ADAPTER_ADDRESSES pa0 = NULL, pap;
   PIP_ADAPTER_UNICAST_ADDRESS pua;
index fa9d4c7a5501f4dc13aced61fb3397e0736facd8..904184e6358e2bf177feea1471095fb066b0402a 100644 (file)
@@ -1,6 +1,6 @@
 /* fhandler_registry.cc: fhandler for /proc/registry virtual filesystem
 
-   Copyright 2002, 2003, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
+   Copyright 2002, 2003, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Red Hat, Inc.
 
 This file is part of Cygwin.
 
This page took 0.044475 seconds and 5 git commands to generate.