/[hurd]/hurd/libcons/vcons-open.c
ViewVC logotype

Diff of /hurd/libcons/vcons-open.c

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

revision 1.1 by marcus, Thu Aug 22 19:24:19 2002 UTC revision 1.2 by marcus, Sun Sep 8 21:55:59 2002 UTC
# Line 29  Line 29 
29    
30  #include "cons.h"  #include "cons.h"
31    
32  /* Open the virtual console VCONS.  VCONS->cons is locked.  */  /* Open the virtual console for VCONS_ENTRY.  CONS is locked.
33       Afterwards, R_VCONS will be locked.  */
34  error_t  error_t
35  cons_vcons_open (vcons_t vcons)  cons_vcons_open (cons_t cons, vcons_list_t vcons_entry, vcons_t *r_vcons)
36  {  {
37    error_t err = 0;    error_t err = 0;
38    char *name;    char *name;
# Line 40  cons_vcons_open (vcons_t vcons) Line 41  cons_vcons_open (vcons_t vcons)
41    int fd = -1;    int fd = -1;
42    struct stat statbuf;    struct stat statbuf;
43    mach_port_t notify = MACH_PORT_NULL;    mach_port_t notify = MACH_PORT_NULL;
44      vcons_t vcons;
45    
46    if (asprintf (&name, "%u", vcons->id) < 0)    if (asprintf (&name, "%u", vcons_entry->id) < 0)
47      return err;      return err;
48    
49      /* Set up the port we receive notification messages on.  */
50      err = ports_create_port (cons_port_class, cons_port_bucket,
51                               sizeof (*vcons), &vcons);
52      if (err)
53        goto err;
54      vcons->notify.cons = NULL;
55      vcons->cons = cons;
56      vcons->vcons_entry = vcons_entry;
57      vcons->id = vcons_entry->id;
58    
59    /* Open the directory port of the virtual console.  */    /* Open the directory port of the virtual console.  */
60    vconsp = file_name_lookup_under (vcons->cons->dirport, name,    vconsp = file_name_lookup_under (cons->dirport, name,
61                                     O_DIRECTORY | O_RDONLY, 0);                                     O_DIRECTORY | O_RDONLY, 0);
62    if (vconsp == MACH_PORT_NULL)    if (vconsp == MACH_PORT_NULL)
63      {      {
# Line 116  cons_vcons_open (vcons_t vcons) Line 128  cons_vcons_open (vcons_t vcons)
128    vcons->state.changes.buffer = ((uint32_t *) vcons->display)    vcons->state.changes.buffer = ((uint32_t *) vcons->display)
129      + vcons->display->changes.buffer;      + vcons->display->changes.buffer;
130    
   /* Set up the port we receive notification messages on.  */  
   err = ports_create_port (cons_port_class, cons_port_bucket,  
                            sizeof (*vcons->notify), &vcons->notify);  
   if (err)  
     goto err;  
   vcons->notify->cons = NULL;  
   vcons->notify->vcons = vcons;  
   
131    /* Request notification messages.  */    /* Request notification messages.  */
132    notify = ports_get_right (vcons->notify);    notify = ports_get_right (vcons);
133    mach_port_set_qlimit (mach_task_self (), notify, 1);    mach_port_set_qlimit (mach_task_self (), notify, 1);
134    
135    /* When this succeeds, we will immediately receive notification    /* When this succeeds, we will immediately receive notification
136       messages for this virtual console.  */       messages for this virtual console.  */
137      mutex_lock (&vcons->lock);
138    err = file_notice_changes (file, notify, MACH_MSG_TYPE_MAKE_SEND);    err = file_notice_changes (file, notify, MACH_MSG_TYPE_MAKE_SEND);
139    if (!err)    if (!err)
140      goto out;      {
141          *r_vcons = vcons;
142          goto out;
143        }
144    
145   err:   err:
146    if (vcons->input >= 0)    if (vcons->input >= 0)
# Line 148  cons_vcons_open (vcons_t vcons) Line 156  cons_vcons_open (vcons_t vcons)
156    if (notify)    if (notify)
157      {      {
158        mach_port_deallocate (mach_task_self (), notify);        mach_port_deallocate (mach_task_self (), notify);
159        vcons->notify = MACH_PORT_NULL;        ports_port_deref (vcons);
160      }      }
161      ports_destroy_right (vcons);
162   out:   out:
163    if (fd > 0)    if (fd > 0)
164      close (fd);      close (fd);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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