mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 00:10:10 +00:00
* hurd/hurd/lookup.h: New file.
* hurd/hurdlookup.c (__file_name_lookup_under): New function. (__hurd_file_name_lookup, __hurd_file_name_lookup_retry, __hurd_file_name_split): Rewritten to take callback functions for using any needed init or dtable port, instead of passing in crdir and cwdir ports. (__file_name_lookup, __file_name_split): Use new calling convention; pass _hurd_ports_use and __getdport as the callback functions. * sysdeps/mach/hurd/chroot.c: Use __file_name_lookup_under instead of __hurd_file_name_lookup. * sysdeps/mach/hurd/chdir.c: Likewise. * sysdeps/mach/hurd/fchdir.c: Likewise. * hurd/fchroot.c: Likewise.
This commit is contained in:
parent
6cab5056c4
commit
2948fc64a6
16
ChangeLog
16
ChangeLog
@ -1,5 +1,21 @@
|
|||||||
Sun Oct 15 21:04:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
Sun Oct 15 21:04:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* hurd/hurd/lookup.h: New file.
|
||||||
|
* hurd/hurdlookup.c (__file_name_lookup_under): New function.
|
||||||
|
(__hurd_file_name_lookup, __hurd_file_name_lookup_retry,
|
||||||
|
__hurd_file_name_split): Rewritten to take callback functions for
|
||||||
|
using any needed init or dtable port, instead of passing in crdir
|
||||||
|
and cwdir ports.
|
||||||
|
(__file_name_lookup, __file_name_split): Use new calling
|
||||||
|
convention; pass _hurd_ports_use and __getdport as the callback
|
||||||
|
functions.
|
||||||
|
|
||||||
|
* sysdeps/mach/hurd/chroot.c: Use __file_name_lookup_under instead
|
||||||
|
of __hurd_file_name_lookup.
|
||||||
|
* sysdeps/mach/hurd/chdir.c: Likewise.
|
||||||
|
* sysdeps/mach/hurd/fchdir.c: Likewise.
|
||||||
|
* hurd/fchroot.c: Likewise.
|
||||||
|
|
||||||
* stdlib/Makefile (mpn-found): Don't omit %.s.
|
* stdlib/Makefile (mpn-found): Don't omit %.s.
|
||||||
(mpn-copy-sysdep): Omit files in nonexistent directories.
|
(mpn-copy-sysdep): Omit files in nonexistent directories.
|
||||||
(copy-mpn): Commit files to CVS.
|
(copy-mpn): Commit files to CVS.
|
||||||
|
36
configure
vendored
36
configure
vendored
@ -707,22 +707,18 @@ os=$config_os
|
|||||||
# Expand the configuration machine name into a subdirectory by architecture
|
# Expand the configuration machine name into a subdirectory by architecture
|
||||||
# type and particular chip.
|
# type and particular chip.
|
||||||
case "$machine" in
|
case "$machine" in
|
||||||
i[345]86)
|
a29k | am29000) machine=a29k ;;
|
||||||
machine=i386/$machine ;;
|
alpha*) machine=alpha/$machine ;;
|
||||||
sparc[6789])
|
hppa*) machine=hppa/$machine ;;
|
||||||
machine=sparc/$machine ;;
|
i[345]86) machine=i386/$machine ;;
|
||||||
m68k)
|
m680?0) machine=m68k/$machine ;;
|
||||||
machine=m68k/m68020 ;;
|
m68k) machine=m68k/m68020 ;;
|
||||||
m680?0)
|
m88???) machine=m88k/$machine ;;
|
||||||
machine=m68k/$machine ;;
|
m88k) machine=m88k/m88100 ;;
|
||||||
m88k)
|
mips*) machine=mips/$machine ;;
|
||||||
machine=m88k/m88100 ;;
|
mips64*) machine=mips/mips64/$machine ;;
|
||||||
m88???)
|
sparc[6789]) machine=sparc/$machine ;;
|
||||||
machine=m88k/$machine ;;
|
supersparc) machine=sparc/sparc8 ;;
|
||||||
mips64*)
|
|
||||||
machine=mips/mips64/$machine ;;
|
|
||||||
mips*)
|
|
||||||
machine=mips/$machine ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
|
# Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
|
||||||
@ -1116,7 +1112,7 @@ else
|
|||||||
# On the NeXT, cc -E runs the code through the compiler's parser,
|
# On the NeXT, cc -E runs the code through the compiler's parser,
|
||||||
# not just through cpp.
|
# not just through cpp.
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1120 "configure"
|
#line 1116 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
Syntax Error
|
Syntax Error
|
||||||
@ -1130,7 +1126,7 @@ else
|
|||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
CPP="${CC-cc} -E -traditional-cpp"
|
CPP="${CC-cc} -E -traditional-cpp"
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1134 "configure"
|
#line 1130 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
Syntax Error
|
Syntax Error
|
||||||
@ -1184,7 +1180,7 @@ if eval "test \"`echo '$''{'libc_cv_friendly_stddef'+set}'`\" = set"; then
|
|||||||
echo $ac_n "(cached) $ac_c" 1>&4
|
echo $ac_n "(cached) $ac_c" 1>&4
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1188 "configure"
|
#line 1184 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#define __need_size_t
|
#define __need_size_t
|
||||||
#define __need_wchar_t
|
#define __need_wchar_t
|
||||||
@ -1307,7 +1303,7 @@ if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
|
|||||||
echo $ac_n "(cached) $ac_c" 1>&4
|
echo $ac_n "(cached) $ac_c" 1>&4
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 1311 "configure"
|
#line 1307 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
int main() { return 0; }
|
int main() { return 0; }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -28,16 +28,12 @@ DEFUN(fchroot, (fd), int fd)
|
|||||||
error_t err;
|
error_t err;
|
||||||
file_t dir;
|
file_t dir;
|
||||||
|
|
||||||
err = __USEPORT (CRDIR,
|
err = HURD_DPORT_USE (fd, (dir = __file_name_lookup_under (port, "",
|
||||||
({ file_t crdir = port;
|
O_EXEC, 0),
|
||||||
HURD_DPORT_USE (fd,
|
errno));
|
||||||
__hurd_file_name_lookup (crdir, port, "",
|
|
||||||
0, 0, &dir));
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (err)
|
if (! err)
|
||||||
return __hurd_fail (err);
|
_hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir);
|
||||||
|
|
||||||
_hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir);
|
return err ? __hurd_fail (err) : 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
101
hurd/hurd/lookup.h
Normal file
101
hurd/hurd/lookup.h
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/* Declarations of file name translation functions for the GNU Hurd.
|
||||||
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#ifndef _HURD_LOOKUP_H
|
||||||
|
#define _HURD_LOOKUP_H 1
|
||||||
|
|
||||||
|
/* These functions all take two callback functions as the first two arguments.
|
||||||
|
The first callback function USE_INIT_PORT is called as follows:
|
||||||
|
|
||||||
|
error_t use_init_port (int which, error_t (*operate) (mach_port_t));
|
||||||
|
|
||||||
|
WHICH is nonnegative value less than INIT_PORT_MAX, indicating which
|
||||||
|
init port is required. The callback function should call *OPERATE
|
||||||
|
with a send right to the appropriate init port. No user reference
|
||||||
|
is consumed; the right will only be used after *OPERATE returns if
|
||||||
|
*OPERATE has added its own user reference.
|
||||||
|
|
||||||
|
The second callback function GET_DTABLE_PORT should behave like `getdport'.
|
||||||
|
|
||||||
|
All these functions return zero on success or an error code on failure. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Open a port to FILE with the given FLAGS and MODE (see <fcntl.h>). If
|
||||||
|
successful, returns zero and store the port to FILE in *PORT; otherwise
|
||||||
|
returns an error code. */
|
||||||
|
|
||||||
|
error_t __hurd_file_name_lookup (error_t (*use_init_port)
|
||||||
|
(int which,
|
||||||
|
error_t (*operate) (mach_port_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
|
const char *file_name,
|
||||||
|
int flags, mode_t mode,
|
||||||
|
file_t *result);
|
||||||
|
error_t hurd_file_name_lookup (error_t (*use_init_port)
|
||||||
|
(int which,
|
||||||
|
error_t (*operate) (mach_port_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
|
const char *file_name,
|
||||||
|
int flags, mode_t mode,
|
||||||
|
file_t *result);
|
||||||
|
|
||||||
|
|
||||||
|
/* Split FILE into a directory and a name within the directory. Look up a
|
||||||
|
port for the directory and store it in *DIR; store in *NAME a pointer
|
||||||
|
into FILE where the name within directory begins. */
|
||||||
|
|
||||||
|
error_t __hurd_file_name_split (error_t (*use_init_port)
|
||||||
|
(int which,
|
||||||
|
error_t (*operate) (mach_port_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
|
const char *file_name,
|
||||||
|
file_t *dir, char **name);
|
||||||
|
error_t hurd_file_name_split (error_t (*use_init_port)
|
||||||
|
(int which,
|
||||||
|
error_t (*operate) (mach_port_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
|
const char *file_name,
|
||||||
|
file_t *dir, char **name);
|
||||||
|
|
||||||
|
|
||||||
|
/* Process the values returned by `dir_lookup' et al, and loop doing
|
||||||
|
`dir_lookup' calls until one returns FS_RETRY_NONE. The arguments
|
||||||
|
should be those just passed to and/or returned from `dir_lookup',
|
||||||
|
`fsys_getroot', or `file_invoke_translator'. This function consumes the
|
||||||
|
reference in *RESULT even if it returns an error. */
|
||||||
|
|
||||||
|
error_t __hurd_file_name_lookup_retry (error_t (*use_init_port)
|
||||||
|
(int which,
|
||||||
|
error_t (*operate) (mach_port_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
|
enum retry_type doretry,
|
||||||
|
char retryname[1024],
|
||||||
|
int flags, mode_t mode,
|
||||||
|
file_t *result);
|
||||||
|
error_t hurd_file_name_lookup_retry (error_t (*use_init_port)
|
||||||
|
(int which,
|
||||||
|
error_t (*operate) (mach_port_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
|
enum retry_type doretry,
|
||||||
|
char retryname[1024],
|
||||||
|
int flags, mode_t mode,
|
||||||
|
file_t *result);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* hurd/lookup.h */
|
@ -17,6 +17,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
|||||||
Cambridge, MA 02139, USA. */
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
|
#include <hurd/lookup.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -41,73 +42,88 @@ lookup_error (error_t error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
error_t
|
error_t
|
||||||
__hurd_file_name_lookup (file_t crdir, file_t cwdir,
|
__hurd_file_name_lookup (error_t (*use_init_port)
|
||||||
|
(int which, error_t (*operate) (file_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
const char *file_name, int flags, mode_t mode,
|
const char *file_name, int flags, mode_t mode,
|
||||||
file_t *result)
|
file_t *result)
|
||||||
{
|
{
|
||||||
error_t err;
|
error_t err;
|
||||||
enum retry_type doretry;
|
enum retry_type doretry;
|
||||||
char retryname[1024]; /* XXX string_t LOSES! */
|
char retryname[1024]; /* XXX string_t LOSES! */
|
||||||
file_t startdir;
|
|
||||||
|
|
||||||
startdir = file_name[0] == '/' ? crdir : cwdir;
|
error_t lookup (mach_port_t startdir)
|
||||||
|
{
|
||||||
|
while (file_name[0] == '/')
|
||||||
|
file_name++;
|
||||||
|
|
||||||
while (file_name[0] == '/')
|
return lookup_error (__dir_lookup (startdir, file_name, flags, mode,
|
||||||
file_name++;
|
&doretry, retryname, result));
|
||||||
|
}
|
||||||
|
|
||||||
if (err = __dir_lookup (startdir, file_name, flags, mode,
|
err = (*use_init_port) (file_name[0] == '/'
|
||||||
&doretry, retryname, result))
|
? INIT_PORT_CRDIR : INIT_PORT_CWDIR,
|
||||||
return lookup_error (err);
|
&lookup);
|
||||||
|
if (! err)
|
||||||
|
err = __hurd_file_name_lookup_retry (use_init_port, get_dtable_port,
|
||||||
|
doretry, retryname, flags, mode,
|
||||||
|
result);
|
||||||
|
|
||||||
return __hurd_file_name_lookup_retry (crdir, doretry, retryname, flags, mode,
|
return err;
|
||||||
result);
|
|
||||||
}
|
}
|
||||||
weak_alias (__hurd_file_name_lookup, hurd_file_name_lookup)
|
weak_alias (__hurd_file_name_lookup, hurd_file_name_lookup)
|
||||||
|
|
||||||
error_t
|
error_t
|
||||||
__hurd_file_name_lookup_retry (file_t crdir,
|
__hurd_file_name_lookup_retry (error_t (*use_init_port)
|
||||||
|
(int which, error_t (*operate) (file_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
enum retry_type doretry,
|
enum retry_type doretry,
|
||||||
char retryname[1024],
|
char retryname[1024],
|
||||||
int flags, mode_t mode,
|
int flags, mode_t mode,
|
||||||
file_t *result)
|
file_t *result)
|
||||||
{
|
{
|
||||||
error_t err;
|
error_t err;
|
||||||
file_t startdir;
|
|
||||||
file_t newpt;
|
|
||||||
char *file_name;
|
char *file_name;
|
||||||
int dealloc_dir;
|
|
||||||
int nloops;
|
int nloops;
|
||||||
|
|
||||||
dealloc_dir = 0;
|
error_t lookup (file_t startdir)
|
||||||
|
{
|
||||||
|
while (file_name[0] == '/')
|
||||||
|
file_name++;
|
||||||
|
|
||||||
|
return lookup_error (__dir_lookup (startdir, file_name, flags, mode,
|
||||||
|
&doretry, retryname, result));
|
||||||
|
}
|
||||||
|
error_t reauthenticate (file_t unauth)
|
||||||
|
{
|
||||||
|
error_t err;
|
||||||
|
mach_port_t ref = __mach_reply_port ();
|
||||||
|
error_t reauth (auth_t auth)
|
||||||
|
{
|
||||||
|
return __auth_user_authenticate (auth, unauth, ref,
|
||||||
|
MACH_MSG_TYPE_MAKE_SEND,
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
err = __io_reauthenticate (unauth, ref, MACH_MSG_TYPE_MAKE_SEND);
|
||||||
|
if (! err)
|
||||||
|
err = (*use_init_port) (INIT_PORT_AUTH, &reauth);
|
||||||
|
__mach_port_destroy (__mach_task_self (), ref);
|
||||||
|
__mach_port_deallocate (__mach_task_self (), unauth);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
nloops = 0;
|
nloops = 0;
|
||||||
err = 0;
|
err = 0;
|
||||||
|
do
|
||||||
while (1)
|
|
||||||
{
|
{
|
||||||
if (dealloc_dir)
|
file_t startdir = MACH_PORT_NULL;
|
||||||
__mach_port_deallocate (__mach_task_self (), startdir);
|
int dirport = INIT_PORT_CWDIR;
|
||||||
if (err)
|
|
||||||
return lookup_error (err);
|
|
||||||
|
|
||||||
switch (doretry)
|
switch (doretry)
|
||||||
{
|
{
|
||||||
case FS_RETRY_REAUTH:
|
case FS_RETRY_REAUTH:
|
||||||
{
|
if (err = reauthenticate (*result))
|
||||||
mach_port_t ref = __mach_reply_port ();
|
|
||||||
err = __io_reauthenticate (*result,
|
|
||||||
ref, MACH_MSG_TYPE_MAKE_SEND);
|
|
||||||
if (! err)
|
|
||||||
err = __USEPORT
|
|
||||||
(AUTH, __auth_user_authenticate (port, *result,
|
|
||||||
ref,
|
|
||||||
MACH_MSG_TYPE_MAKE_SEND,
|
|
||||||
&newpt));
|
|
||||||
__mach_port_destroy (__mach_task_self (), ref);
|
|
||||||
}
|
|
||||||
__mach_port_deallocate (__mach_task_self (), *result);
|
|
||||||
if (err)
|
|
||||||
return err;
|
return err;
|
||||||
*result = newpt;
|
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
|
|
||||||
case FS_RETRY_NORMAL:
|
case FS_RETRY_NORMAL:
|
||||||
@ -134,7 +150,6 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
startdir = *result;
|
startdir = *result;
|
||||||
dealloc_dir = 1;
|
|
||||||
file_name = retryname;
|
file_name = retryname;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -142,8 +157,7 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
switch (retryname[0])
|
switch (retryname[0])
|
||||||
{
|
{
|
||||||
case '/':
|
case '/':
|
||||||
startdir = crdir;
|
dirport = INIT_PORT_CRDIR;
|
||||||
dealloc_dir = 0;
|
|
||||||
if (*result != MACH_PORT_NULL)
|
if (*result != MACH_PORT_NULL)
|
||||||
__mach_port_deallocate (__mach_task_self (), *result);
|
__mach_port_deallocate (__mach_task_self (), *result);
|
||||||
file_name = &retryname[1];
|
file_name = &retryname[1];
|
||||||
@ -166,24 +180,29 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
errno = save;
|
errno = save;
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
*result = __getdport (fd);
|
if (! get_dtable_port)
|
||||||
if (*result == MACH_PORT_NULL)
|
err = EGRATUITOUS;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* If the name was a proper number, but the file
|
*result = (*get_dtable_port) (fd);
|
||||||
descriptor does not exist, we return EBADF instead
|
if (*result == MACH_PORT_NULL)
|
||||||
of ENOENT. */
|
{
|
||||||
error_t err = errno;
|
/* If the name was a proper number, but the file
|
||||||
errno = save;
|
descriptor does not exist, we return EBADF instead
|
||||||
return err;
|
of ENOENT. */
|
||||||
|
err = errno;
|
||||||
|
errno = save;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
errno = save;
|
errno = save;
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
if (*end == '\0')
|
if (*end == '\0')
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Do a normal retry on the remaining components. */
|
/* Do a normal retry on the remaining components. */
|
||||||
startdir = *result;
|
startdir = *result;
|
||||||
dealloc_dir = 1;
|
|
||||||
file_name = end + 1; /* Skip the slash. */
|
file_name = end + 1; /* Skip the slash. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -202,6 +221,7 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
struct host_basic_info hostinfo;
|
struct host_basic_info hostinfo;
|
||||||
mach_msg_type_number_t hostinfocnt = HOST_BASIC_INFO_COUNT;
|
mach_msg_type_number_t hostinfocnt = HOST_BASIC_INFO_COUNT;
|
||||||
char *p;
|
char *p;
|
||||||
|
/* XXX want client's host */
|
||||||
if (err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
|
if (err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
|
||||||
(natural_t *) &hostinfo,
|
(natural_t *) &hostinfo,
|
||||||
&hostinfocnt))
|
&hostinfocnt))
|
||||||
@ -216,7 +236,6 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
if (p > retryname)
|
if (p > retryname)
|
||||||
strcpy (retryname, p);
|
strcpy (retryname, p);
|
||||||
startdir = *result;
|
startdir = *result;
|
||||||
dealloc_dir = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto bad_magic;
|
goto bad_magic;
|
||||||
@ -229,29 +248,15 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
error_t opentty (file_t *result)
|
error_t opentty (file_t *result)
|
||||||
{
|
{
|
||||||
error_t err;
|
error_t err;
|
||||||
file_t unauth;
|
error_t ctty_open (file_t port)
|
||||||
err = __USEPORT (CTTYID,
|
|
||||||
__termctty_open_terminal (port,
|
|
||||||
flags,
|
|
||||||
&unauth));
|
|
||||||
if (! err)
|
|
||||||
{
|
{
|
||||||
mach_port_t ref = __mach_reply_port ();
|
return __termctty_open_terminal (port,
|
||||||
err = __io_reauthenticate
|
flags,
|
||||||
(unauth,
|
result);
|
||||||
ref,
|
|
||||||
MACH_MSG_TYPE_MAKE_SEND);
|
|
||||||
if (! err)
|
|
||||||
err = __USEPORT
|
|
||||||
(AUTH, __auth_user_authenticate
|
|
||||||
(port,
|
|
||||||
unauth,
|
|
||||||
ref, MACH_MSG_TYPE_MAKE_SEND,
|
|
||||||
result));
|
|
||||||
__mach_port_deallocate (__mach_task_self (),
|
|
||||||
unauth);
|
|
||||||
__mach_port_destroy (__mach_task_self (), ref);
|
|
||||||
}
|
}
|
||||||
|
err = (*use_init_port) (INIT_PORT_CTTYID, &ctty_open);
|
||||||
|
if (! err)
|
||||||
|
err = reauthenticate (*result);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +265,6 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
case '/':
|
case '/':
|
||||||
if (err = opentty (&startdir))
|
if (err = opentty (&startdir))
|
||||||
return err;
|
return err;
|
||||||
dealloc_dir = 1;
|
|
||||||
strcpy (retryname, &retryname[4]);
|
strcpy (retryname, &retryname[4]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -280,32 +284,43 @@ __hurd_file_name_lookup_retry (file_t crdir,
|
|||||||
return EGRATUITOUS;
|
return EGRATUITOUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = __dir_lookup (startdir, file_name, flags, mode,
|
if (startdir != MACH_PORT_NULL)
|
||||||
&doretry, retryname, result);
|
{
|
||||||
}
|
err = lookup (startdir);
|
||||||
|
__mach_port_deallocate (__mach_task_self (), startdir);
|
||||||
|
startdir = MACH_PORT_NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
err = (*use_init_port) (dirport, &lookup);
|
||||||
|
} while (! err);
|
||||||
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
weak_alias (__hurd_file_name_lookup_retry, hurd_file_name_lookup_retry)
|
weak_alias (__hurd_file_name_lookup_retry, hurd_file_name_lookup_retry)
|
||||||
|
|
||||||
error_t
|
error_t
|
||||||
__hurd_file_name_split (file_t crdir, file_t cwdir,
|
__hurd_file_name_split (error_t (*use_init_port)
|
||||||
|
(int which, error_t (*operate) (file_t)),
|
||||||
|
file_t (*get_dtable_port) (int fd),
|
||||||
const char *file_name,
|
const char *file_name,
|
||||||
file_t *dir, char **name)
|
file_t *dir, char **name)
|
||||||
{
|
{
|
||||||
const char *lastslash;
|
error_t addref (file_t crdir)
|
||||||
error_t err;
|
{
|
||||||
|
*dir = crdir;
|
||||||
|
return __mach_port_mod_refs (__mach_task_self (),
|
||||||
|
crdir, MACH_PORT_RIGHT_SEND, +1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *lastslash = strrchr (file_name, '/');
|
||||||
|
|
||||||
lastslash = strrchr (file_name, '/');
|
|
||||||
if (lastslash != NULL)
|
if (lastslash != NULL)
|
||||||
{
|
{
|
||||||
if (lastslash == file_name)
|
if (lastslash == file_name)
|
||||||
{
|
{
|
||||||
/* "/foobar" => crdir + "foobar". */
|
/* "/foobar" => crdir + "foobar". */
|
||||||
*name = (char *) file_name + 1;
|
*name = (char *) file_name + 1;
|
||||||
if (err = __mach_port_mod_refs (__mach_task_self (),
|
return (*use_init_port) (INIT_PORT_CRDIR, &addref);
|
||||||
crdir, MACH_PORT_RIGHT_SEND, +1))
|
|
||||||
return err;
|
|
||||||
*dir = crdir;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -314,18 +329,15 @@ __hurd_file_name_split (file_t crdir, file_t cwdir,
|
|||||||
memcpy (dirname, file_name, lastslash - file_name);
|
memcpy (dirname, file_name, lastslash - file_name);
|
||||||
dirname[lastslash - file_name] = '\0';
|
dirname[lastslash - file_name] = '\0';
|
||||||
*name = (char *) lastslash + 1;
|
*name = (char *) lastslash + 1;
|
||||||
return __hurd_file_name_lookup (crdir, cwdir, dirname, 0, 0, dir);
|
return __hurd_file_name_lookup (use_init_port, get_dtable_port,
|
||||||
|
dirname, 0, 0, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* "foobar" => cwdir + "foobar". */
|
/* "foobar" => cwdir + "foobar". */
|
||||||
*name = (char *) file_name;
|
*name = (char *) file_name;
|
||||||
if (err = __mach_port_mod_refs (__mach_task_self (),
|
return (*use_init_port) (INIT_PORT_CWDIR, &addref);
|
||||||
cwdir, MACH_PORT_RIGHT_SEND, +1))
|
|
||||||
return err;
|
|
||||||
*dir = cwdir;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
weak_alias (__hurd_file_name_split, hurd_file_name_split)
|
weak_alias (__hurd_file_name_split, hurd_file_name_split)
|
||||||
@ -335,22 +347,13 @@ file_t
|
|||||||
__file_name_lookup (const char *file_name, int flags, mode_t mode)
|
__file_name_lookup (const char *file_name, int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
error_t err;
|
error_t err;
|
||||||
file_t result, crdir, cwdir;
|
file_t result;
|
||||||
struct hurd_userlink crdir_ulink, cwdir_ulink;
|
|
||||||
|
|
||||||
crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink);
|
err = __hurd_file_name_lookup (&_hurd_ports_use, &__getdport,
|
||||||
cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink);
|
file_name, flags, mode,
|
||||||
|
|
||||||
err = __hurd_file_name_lookup (crdir, cwdir, file_name, flags, mode,
|
|
||||||
&result);
|
&result);
|
||||||
|
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
|
return err ? (__hurd_fail (err), MACH_PORT_NULL) : result;
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir);
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
return __hurd_fail (err), MACH_PORT_NULL;
|
|
||||||
else
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
weak_alias (__file_name_lookup, file_name_lookup)
|
weak_alias (__file_name_lookup, file_name_lookup)
|
||||||
|
|
||||||
@ -359,23 +362,33 @@ file_t
|
|||||||
__file_name_split (const char *file_name, char **name)
|
__file_name_split (const char *file_name, char **name)
|
||||||
{
|
{
|
||||||
error_t err;
|
error_t err;
|
||||||
file_t dir, crdir, cwdir;
|
file_t result;
|
||||||
struct hurd_userlink crdir_ulink, cwdir_ulink;
|
|
||||||
|
|
||||||
crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink);
|
err = __hurd_file_name_split (&_hurd_ports_use, &__getdport,
|
||||||
cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink);
|
file_name, &result, name);
|
||||||
|
|
||||||
err = __hurd_file_name_split (crdir, cwdir, file_name, &dir, name);
|
return err ? (__hurd_fail (err), MACH_PORT_NULL) : result;
|
||||||
|
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
|
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir);
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
errno = err;
|
|
||||||
return MACH_PORT_NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return dir;
|
|
||||||
}
|
}
|
||||||
weak_alias (__file_name_split, file_name_split)
|
weak_alias (__file_name_split, file_name_split)
|
||||||
|
|
||||||
|
|
||||||
|
file_t
|
||||||
|
__file_name_lookup_under (file_t startdir,
|
||||||
|
const char *file_name, int flags, mode_t mode)
|
||||||
|
{
|
||||||
|
error_t err;
|
||||||
|
file_t result;
|
||||||
|
|
||||||
|
error_t use_init_port (int which, error_t (*operate) (mach_port_t))
|
||||||
|
{
|
||||||
|
return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
|
||||||
|
_hurd_ports_use (which, operate));
|
||||||
|
}
|
||||||
|
|
||||||
|
err = __hurd_file_name_lookup (&use_init_port, &__getdport,
|
||||||
|
file_name, flags, mode,
|
||||||
|
&result);
|
||||||
|
|
||||||
|
return err ? (__hurd_fail (err), MACH_PORT_NULL) : result;
|
||||||
|
}
|
||||||
|
weak_alias (__file_name_lookup_under, file_name_lookup_under)
|
||||||
|
@ -27,16 +27,14 @@ int
|
|||||||
DEFUN(__chdir, (file_name), CONST char *file_name)
|
DEFUN(__chdir, (file_name), CONST char *file_name)
|
||||||
{
|
{
|
||||||
file_t file, dir;
|
file_t file, dir;
|
||||||
error_t err;
|
|
||||||
|
|
||||||
file = __file_name_lookup (file_name, O_EXEC, 0);
|
file = __file_name_lookup (file_name, O_EXEC, 0);
|
||||||
if (file == MACH_PORT_NULL)
|
if (file == MACH_PORT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
err = __USEPORT (CRDIR, __hurd_file_name_lookup (port, file, "",
|
dir = __file_name_lookup_under (file, "", O_EXEC, 0);
|
||||||
O_EXEC, 0, &dir));
|
|
||||||
__mach_port_deallocate (__mach_task_self (), file);
|
__mach_port_deallocate (__mach_task_self (), file);
|
||||||
if (err)
|
if (dir == MACH_PORT_NULL)
|
||||||
return __hurd_fail (err);
|
return -1;
|
||||||
|
|
||||||
_hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], dir);
|
_hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], dir);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -29,16 +29,14 @@ int
|
|||||||
DEFUN(chroot, (file_name), CONST char *file_name)
|
DEFUN(chroot, (file_name), CONST char *file_name)
|
||||||
{
|
{
|
||||||
file_t file, dir;
|
file_t file, dir;
|
||||||
error_t err;
|
|
||||||
|
|
||||||
file = __file_name_lookup (file_name, O_EXEC, 0);
|
file = __file_name_lookup (file_name, O_EXEC, 0);
|
||||||
if (file == MACH_PORT_NULL)
|
if (file == MACH_PORT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
err = __USEPORT (CRDIR, __hurd_file_name_lookup (port, file, "",
|
dir = __file_name_lookup_under (file, "", O_EXEC, 0);
|
||||||
O_EXEC, 0, &dir));
|
|
||||||
__mach_port_deallocate (__mach_task_self (), file);
|
__mach_port_deallocate (__mach_task_self (), file);
|
||||||
if (err)
|
if (dir == MACH_PORT_NULL)
|
||||||
return __hurd_fail (err);
|
return -1;
|
||||||
|
|
||||||
_hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir);
|
_hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -28,18 +28,14 @@ int
|
|||||||
DEFUN(fchdir, (fd), int fd)
|
DEFUN(fchdir, (fd), int fd)
|
||||||
{
|
{
|
||||||
error_t err;
|
error_t err;
|
||||||
file_t cwdir;
|
file_t dir;
|
||||||
|
|
||||||
err = __USEPORT (CRDIR,
|
err = HURD_DPORT_USE (fd, (dir = __file_name_lookup_under (port, "",
|
||||||
({ file_t crdir = port;
|
O_EXEC, 0),
|
||||||
HURD_DPORT_USE (fd,
|
errno));
|
||||||
__hurd_file_name_lookup (crdir, port, "",
|
|
||||||
0, 0, &cwdir));
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (err)
|
if (! err)
|
||||||
return __hurd_fail (err);
|
_hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], dir);
|
||||||
|
|
||||||
_hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], cwdir);
|
return err ? __hurd_fail (err) : 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user