/[hurd]/hurd/term/main.c
ViewVC logotype

Diff of /hurd/term/main.c

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

revision 1.27 by marcus, Tue Mar 5 02:17:04 2002 UTC revision 1.28 by neal, Tue Mar 26 19:11:01 2002 UTC
# Line 26  Line 26 
26  #include <argp.h>  #include <argp.h>
27  #include <hurd/fsys.h>  #include <hurd/fsys.h>
28  #include <string.h>  #include <string.h>
29    #include <error.h>
30    
31  #include <version.h>  #include <version.h>
32    
# Line 148  main (int argc, char **argv) Line 149  main (int argc, char **argv)
149    struct trivfs_control **ourcntl, **peercntl;    struct trivfs_control **ourcntl, **peercntl;
150    mach_port_t bootstrap, right;    mach_port_t bootstrap, right;
151    struct stat st;    struct stat st;
152      error_t err;
153    
154    term_bucket = ports_create_bucket ();    term_bucket = ports_create_bucket ();
155        
# Line 206  main (int argc, char **argv) Line 208  main (int argc, char **argv)
208    
209      default:      default:
210        /* Should not happen.  */        /* Should not happen.  */
211        fprintf (stderr, "Unknown terminal type\n");        error (1, 0, "Unknown terminal type");
       exit (1);  
212      }      }
213        
214    task_get_bootstrap_port (mach_task_self (), &bootstrap);    task_get_bootstrap_port (mach_task_self (), &bootstrap);
215        
216    if (bootstrap == MACH_PORT_NULL)    if (bootstrap == MACH_PORT_NULL)
217      {      error (1, 0, "Must be started as a translator");
       fprintf (stderr, "Must be started as a translator\n");  
       exit (1);  
     }  
218    
219    /* Set our node.  */    /* Set our node.  */
220    errno = trivfs_startup (bootstrap, 0,    err = trivfs_startup (bootstrap, 0,
221                            ourcntlclass, term_bucket, ourclass, term_bucket,                          ourcntlclass, term_bucket, ourclass, term_bucket,
222                            ourcntl);                          ourcntl);
223    if (errno)    if (err)
224      {      error (1, err, "Starting translator");
       perror ("Starting translator");  
       exit (1);  
     }  
225    
226    /* For ptys, the nodename depends on which half is used.  For now just use    /* For ptys, the nodename depends on which half is used.  For now just use
227       the hook to store the nodename.  */       the hook to store the nodename.  */
# Line 238  main (int argc, char **argv) Line 233  main (int argc, char **argv)
233        char *peer_name = tty_arg;        char *peer_name = tty_arg;
234        file_t file = file_name_lookup (peer_name, O_CREAT|O_NOTRANS, 0666);        file_t file = file_name_lookup (peer_name, O_CREAT|O_NOTRANS, 0666);
235    
236        if (file != MACH_PORT_NULL)        if (file == MACH_PORT_NULL)
237          errno = 0;          err = errno;
238    
239        if (! errno)        if (! err)
240          errno = trivfs_create_control (file, peercntlclass, term_bucket,          err = trivfs_create_control (file, peercntlclass, term_bucket,
241                                         peerclass, term_bucket, peercntl);                                       peerclass, term_bucket, peercntl);
242        if (! errno)        if (! err)
243          {          {
244            right = ports_get_send_right (*peercntl);            right = ports_get_send_right (*peercntl);
245            errno = file_set_translator (file, 0, FS_TRANS_EXCL | FS_TRANS_SET,            err = file_set_translator (file, 0, FS_TRANS_EXCL | FS_TRANS_SET,
246                                       0, 0, 0, right, MACH_MSG_TYPE_COPY_SEND);                                       0, 0, 0, right, MACH_MSG_TYPE_COPY_SEND);
247            mach_port_deallocate (mach_task_self (), right);            mach_port_deallocate (mach_task_self (), right);
248          }          }
249    
250        if (errno)        if (err)
251          {            error (1, err, peer_name);
           perror (peer_name);  
           exit (1);  
         }  
252    
253        (*peercntl)->hook = peer_name;        (*peercntl)->hook = peer_name;
254        ports_port_deref (*peercntl);        ports_port_deref (*peercntl);
# Line 267  main (int argc, char **argv) Line 259  main (int argc, char **argv)
259    mutex_init (&global_lock);    mutex_init (&global_lock);
260    
261    /* Initialize status from underlying node.  */    /* Initialize status from underlying node.  */
262    errno = io_stat ((*ourcntl)->underlying, &st);    err = io_stat ((*ourcntl)->underlying, &st);
263    if (errno)    if (err)
264      {      {
265        /* We cannot stat the underlying node.  Fallback to the defaults.  */        /* We cannot stat the underlying node.  Fallback to the defaults.  */
266        term_owner = term_group = 0;        term_owner = term_group = 0;
267        term_mode = (bottom == &ptyio_bottom ? DEFFILEMODE : S_IRUSR | S_IWUSR);        term_mode = (bottom == &ptyio_bottom ? DEFFILEMODE : S_IRUSR | S_IWUSR);
       errno = 0;  
268      }      }
269    else    else
270      {      {
# Line 289  main (int argc, char **argv) Line 280  main (int argc, char **argv)
280        
281    outputq = create_queue (256, QUEUE_LOWAT, QUEUE_HIWAT);    outputq = create_queue (256, QUEUE_LOWAT, QUEUE_HIWAT);
282        
283    errno = (*bottom->init) ();    err = (*bottom->init) ();
284    if (errno)    if (err)
285      {      error (1, err, "Initializing bottom handler");
       perror ("Initializing bottom handler");  
       exit (1);  
     }  
286    
287    condition_init (&carrier_alert);    condition_init (&carrier_alert);
288    condition_init (&select_alert);    condition_init (&select_alert);

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

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