/[hurd]/hurd/libnetfs/fsys-getroot.c
ViewVC logotype

Diff of /hurd/libnetfs/fsys-getroot.c

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

revision 1.10 by roland, Sat Jun 16 20:23:29 2001 UTC revision 1.11 by roland, Wed May 8 09:21:38 2002 UTC
# Line 1  Line 1 
1  /*  /*
2     Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.     Copyright (C) 1996,97,2001,02 Free Software Foundation, Inc.
3     Written by Michael I. Bushnell, p/BSG.     Written by Michael I. Bushnell, p/BSG.
4    
5     This file is part of the GNU Hurd.     This file is part of the GNU Hurd.
# Line 35  netfs_S_fsys_getroot (mach_port_t cntl, Line 35  netfs_S_fsys_getroot (mach_port_t cntl,
35                        retry_type *do_retry,                        retry_type *do_retry,
36                        char *retry_name,                        char *retry_name,
37                        mach_port_t *retry_port,                        mach_port_t *retry_port,
38                        mach_port_t *retry_port_type)                        mach_msg_type_name_t *retry_port_type)
39  {  {
40    struct port_info *pt = ports_lookup_port (netfs_port_bucket, cntl,    struct port_info *pt = ports_lookup_port (netfs_port_bucket, cntl,
41                                              netfs_control_class);                                              netfs_control_class);
# Line 52  netfs_S_fsys_getroot (mach_port_t cntl, Line 52  netfs_S_fsys_getroot (mach_port_t cntl,
52    err = iohelp_create_complex_iouser (&cred, uids, nuids, gids, ngids);    err = iohelp_create_complex_iouser (&cred, uids, nuids, gids, ngids);
53    if (err)    if (err)
54      return err;      return err;
55      
56    flags &= O_HURD;    flags &= O_HURD;
57      
58    mutex_lock (&netfs_root_node->lock);    mutex_lock (&netfs_root_node->lock);
59    err = netfs_validate_stat (netfs_root_node, cred);    err = netfs_validate_stat (netfs_root_node, cred);
60    if (err)    if (err)
61      goto out;      goto out;
62      
63    type = netfs_root_node->nn_stat.st_mode & S_IFMT;    type = netfs_root_node->nn_stat.st_mode & S_IFMT;
64    
65    if (((netfs_root_node->nn_stat.st_mode & S_IPTRANS)    if (((netfs_root_node->nn_stat.st_mode & S_IPTRANS)
# Line 82  netfs_S_fsys_getroot (mach_port_t cntl, Line 82  netfs_S_fsys_getroot (mach_port_t cntl,
82        /* ENOENT means translator has vanished inside fshelp_fetch_root. */        /* ENOENT means translator has vanished inside fshelp_fetch_root. */
83        err = 0;        err = 0;
84      }      }
85      
86    if (type == S_IFLNK && !(flags & (O_NOLINK | O_NOTRANS)))    if (type == S_IFLNK && !(flags & (O_NOLINK | O_NOTRANS)))
87      {      {
88        char pathbuf[netfs_root_node->nn_stat.st_size + 1];        char pathbuf[netfs_root_node->nn_stat.st_size + 1];
89          
90        err = netfs_attempt_readlink (cred, netfs_root_node, pathbuf);        err = netfs_attempt_readlink (cred, netfs_root_node, pathbuf);
91    
92        if (err)        if (err)
93          goto out;          goto out;
94          
95        mutex_unlock (&netfs_root_node->lock);        mutex_unlock (&netfs_root_node->lock);
96        iohelp_free_iouser (cred);        iohelp_free_iouser (cred);
97    
# Line 113  netfs_S_fsys_getroot (mach_port_t cntl, Line 113  netfs_S_fsys_getroot (mach_port_t cntl,
113            return 0;            return 0;
114          }          }
115      }      }
116      
117    if ((type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR    if ((type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR
118        || type == S_IFIFO) && (flags & (O_READ|O_WRITE|O_EXEC)))        || type == S_IFIFO) && (flags & (O_READ|O_WRITE|O_EXEC)))
119      {      {
120        err = EOPNOTSUPP;        err = EOPNOTSUPP;
121        goto out;        goto out;
122      }      }
123      
124    err = netfs_check_open_permissions (cred, netfs_root_node, flags, 0);    err = netfs_check_open_permissions (cred, netfs_root_node, flags, 0);
125    if (err)    if (err)
126      goto out;      goto out;
127      
128    flags &= ~OPENONLY_STATE_MODES;    flags &= ~OPENONLY_STATE_MODES;
129      
130    newpi = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,    newpi = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,
131                                                   &peropen_context),                                                   &peropen_context),
132                               cred);                               cred);
# Line 137  netfs_S_fsys_getroot (mach_port_t cntl, Line 137  netfs_S_fsys_getroot (mach_port_t cntl,
137    *retry_port_type = MACH_MSG_TYPE_MAKE_SEND;    *retry_port_type = MACH_MSG_TYPE_MAKE_SEND;
138    retry_name[0] = '\0';    retry_name[0] = '\0';
139    ports_port_deref (newpi);    ports_port_deref (newpi);
140      
141   out:   out:
142    if (err)    if (err)
143      iohelp_free_iouser (cred);      iohelp_free_iouser (cred);
144    mutex_unlock (&netfs_root_node->lock);    mutex_unlock (&netfs_root_node->lock);
145    return err;    return err;
146  }  }
   
     
         

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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