/[hurd]/hurd/console/console.c
ViewVC logotype

Diff of /hurd/console/console.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by marcus, Mon Jun 24 23:46:55 2002 UTC revision 1.14 by marcus, Thu Jun 27 19:19:13 2002 UTC
# Line 43  Line 43 
43  /* We include console.h for the color numbers.  */  /* We include console.h for the color numbers.  */
44  #include "console.h"  #include "console.h"
45    
46    #include "fs_notify_U.h"
47    
48  const char *argp_program_version = STANDARD_HURD_VERSION (console);  const char *argp_program_version = STANDARD_HURD_VERSION (console);
49    
50  char *netfs_server_name = "console";  char *netfs_server_name = "console";
# Line 91  struct vcons Line 93  struct vcons
93    struct node *inpt_node;    struct node *inpt_node;
94  };  };
95    
96    /* Pending directory modification requests.  */
97    struct modreq
98    {
99      mach_port_t port;
100      struct modreq *next;
101    };
102    
103  struct cons  struct cons
104  {  {
105    /* The lock protects the console, all virtual consoles contained in    /* The lock protects the console, all virtual consoles contained in
# Line 104  struct cons Line 113  struct cons
113    int foreground;    int foreground;
114    int background;    int background;
115    
116      /* Requester of directory modification notifications.  */
117      struct modreq *dirmod_reqs;
118      unsigned int dirmod_tick;
119    
120    struct node *node;    struct node *node;
121    mach_port_t underlying;    mach_port_t underlying;
122    /* A template for the stat information of all nodes.  */    /* A template for the stat information of all nodes.  */
# Line 111  struct cons Line 124  struct cons
124  };  };
125    
126    
127    /* Requires CONS to be locked.  */
128    static void
129    cons_notice_dirchange (cons_t cons, dir_changed_type_t type, char *name)
130    {
131      error_t err;
132      struct modreq **preq = &cons->dirmod_reqs;
133    
134      cons->dirmod_tick++;
135      while (*preq)
136        {
137          struct modreq *req = *preq;
138    
139          err = dir_changed (req->port, cons->dirmod_tick, type, name);
140          if (err && err != MACH_SEND_TIMEOUT)
141            {
142              /* Remove notify port.  */
143              *preq = req->next;
144              mach_port_deallocate (mach_task_self (), req->port);
145              free (req);
146            }
147          else
148            preq = &req->next;
149        }
150    }
151    
152    
153  /* Lookup the virtual console with number ID in the console CONS,  /* Lookup the virtual console with number ID in the console CONS,
154     acquire a reference for it, and return it in R_VCONS.  If CREATE is     acquire a reference for it, and return it in R_VCONS.  If CREATE is
155     true, the virtual console will be created if it doesn't exist yet.     true, the virtual console will be created if it doesn't exist yet.
# Line 215  vcons_lookup (cons_t cons, int id, int c Line 254  vcons_lookup (cons_t cons, int id, int c
254          }          }
255        cons->vcons_list = vcons;        cons->vcons_list = vcons;
256      }      }
257      cons_notice_dirchange (cons, DIR_CHANGED_NEW, vcons->name);
258    
259    mutex_unlock (&cons->lock);    mutex_unlock (&cons->lock);
260    *r_vcons = vcons;    *r_vcons = vcons;
261    return 0;    return 0;
# Line 253  vcons_release (vcons_t vcons) Line 294  vcons_release (vcons_t vcons)
294        if (vcons->next)        if (vcons->next)
295          vcons->next->prev = vcons->prev;          vcons->next->prev = vcons->prev;
296    
297          cons_notice_dirchange (cons, DIR_CHANGED_UNLINK, vcons->name);
298    
299        /* XXX Destroy the state.  */        /* XXX Destroy the state.  */
300        display_destroy (vcons->display);        display_destroy (vcons->display);
301        input_destroy (vcons->input);        input_destroy (vcons->input);
# Line 1186  netfs_S_io_map (struct protid *cred, Line 1229  netfs_S_io_map (struct protid *cred,
1229    
1230    
1231  kern_return_t  kern_return_t
1232    netfs_S_dir_notice_changes (struct protid *cred, mach_port_t notify)
1233    {
1234      error_t err;
1235      cons_t cons;
1236      struct modreq *req;
1237    
1238      if (!cred)
1239        return EOPNOTSUPP;
1240    
1241      cons = cred->po->np->nn->cons;
1242      if (!cons)
1243        return EOPNOTSUPP;
1244    
1245      mutex_lock (&cons->lock);
1246      err = dir_changed (notify, cons->dirmod_tick, DIR_CHANGED_NULL, "");
1247      if (err)
1248        {
1249          mutex_unlock (&cons->lock);
1250          return err;
1251        }
1252      req = malloc (sizeof (struct modreq));
1253      if (!req)
1254        {
1255          mutex_unlock (&cons->lock);
1256          return errno;
1257        }
1258      req->port = notify;
1259      req->next = cons->dirmod_reqs;
1260      cons->dirmod_reqs = req;
1261      mutex_unlock (&cons->lock);
1262      return 0;
1263    }
1264    
1265    kern_return_t
1266  netfs_S_file_notice_changes (struct protid *cred, mach_port_t notify)  netfs_S_file_notice_changes (struct protid *cred, mach_port_t notify)
1267  {  {
1268    struct node *np;    struct node *np;
# Line 1676  main (int argc, char **argv) Line 1753  main (int argc, char **argv)
1753    cons->foreground = DEFAULT_FOREGROUND;    cons->foreground = DEFAULT_FOREGROUND;
1754    cons->background = DEFAULT_BACKGROUND;    cons->background = DEFAULT_BACKGROUND;
1755    cons->vcons_list = NULL;    cons->vcons_list = NULL;
1756      cons->dirmod_reqs = NULL;
1757      cons->dirmod_tick = 0;
1758    root_nn.cons = cons;    root_nn.cons = cons;
1759    
1760    /* Parse our command line arguments (all none of them).  */    /* Parse our command line arguments (all none of them).  */

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26