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. |
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); |
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) |
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 |
|
|
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); |
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 |
} |
} |
|
|
|
|
|
|
|
|
|