mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Define a Scheme binding to ‘fchownat’ when it exists.
* configure.ac: Detect whether ‘fchownat’ is available. * libguile/filesys.c (scm_chownat): Define a Scheme binding to ‘fchownat’ when available. * libguile/filesys.h (scm_chownat): Make it part of the API. * doc/ref/posix.texi (File System): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
3b45185d8f
commit
0af3c2f509
4 changed files with 49 additions and 2 deletions
|
@ -509,7 +509,7 @@ AC_CHECK_HEADERS([crt_externs.h])
|
||||||
# isblank - available as a GNU extension or in C99
|
# isblank - available as a GNU extension or in C99
|
||||||
# _NSGetEnviron - Darwin specific
|
# _NSGetEnviron - Darwin specific
|
||||||
# strcoll_l, newlocale, uselocale, utimensat, futimens, fchmodat,
|
# strcoll_l, newlocale, uselocale, utimensat, futimens, fchmodat,
|
||||||
# unlinkat - POSIX.1-2008
|
# unlinkat, fchownat - POSIX.1-2008
|
||||||
# strtol_l - non-POSIX, found in glibc
|
# strtol_l - non-POSIX, found in glibc
|
||||||
# fork - unavailable on Windows
|
# fork - unavailable on Windows
|
||||||
# sched_getaffinity, sched_setaffinity - GNU extensions (glibc)
|
# sched_getaffinity, sched_setaffinity - GNU extensions (glibc)
|
||||||
|
@ -517,7 +517,7 @@ AC_CHECK_HEADERS([crt_externs.h])
|
||||||
# pipe2 - non-POSIX, found in glibc (GNU/Linux and GNU/Hurd)
|
# pipe2 - non-POSIX, found in glibc (GNU/Linux and GNU/Hurd)
|
||||||
#
|
#
|
||||||
AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \
|
AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid \
|
||||||
fesetround ftime ftruncate fchown fchmod fchdir readlinkat \
|
fesetround ftime ftruncate fchown fchownat fchmod fchdir readlinkat \
|
||||||
fchmodat symlinkat mkdirat renameat unlinkat getcwd geteuid getsid \
|
fchmodat symlinkat mkdirat renameat unlinkat getcwd geteuid getsid \
|
||||||
gettimeofday getuid getgid gmtime_r ioctl lstat mkdir mkdtemp mknod \
|
gettimeofday getuid getgid gmtime_r ioctl lstat mkdir mkdtemp mknod \
|
||||||
nice readlink rmdir setegid seteuid \
|
nice readlink rmdir setegid seteuid \
|
||||||
|
|
|
@ -802,6 +802,17 @@ unsupported at present). If @var{owner} or @var{group} is specified
|
||||||
as @code{-1}, then that ID is not changed.
|
as @code{-1}, then that ID is not changed.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@findex fchownat
|
||||||
|
@deffn {Scheme Procedure} chownat dir name owner group [flags]
|
||||||
|
@deffnx {C Function} scm_chownat (dir, name, owner, group, flags)
|
||||||
|
Like @code{chown}, but modify the owner and/or group of
|
||||||
|
the file named @var{name} in the directory referred to
|
||||||
|
by the file port @var{dir} instead. The optional argument
|
||||||
|
@var{flags} is a bitmask. If @code{AT_SYMLINK_NOFOLLOW} is
|
||||||
|
present, then @var{name} will not be dereferenced if it is a
|
||||||
|
symbolic link.
|
||||||
|
@end deffn
|
||||||
|
|
||||||
@findex fchmod
|
@findex fchmod
|
||||||
@deffn {Scheme Procedure} chmod object mode
|
@deffn {Scheme Procedure} chmod object mode
|
||||||
@deffnx {C Function} scm_chmod (object, mode)
|
@deffnx {C Function} scm_chmod (object, mode)
|
||||||
|
|
|
@ -180,6 +180,41 @@ SCM_DEFINE (scm_chown, "chown", 3, 0, 0,
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
#endif /* HAVE_CHOWN */
|
#endif /* HAVE_CHOWN */
|
||||||
|
|
||||||
|
#ifdef HAVE_FCHOWNAT
|
||||||
|
SCM_DEFINE (scm_chownat, "chown-at", 4, 1, 0,
|
||||||
|
(SCM dir, SCM name, SCM owner, SCM group, SCM flags),
|
||||||
|
"Like @code{chown}, but modify the owner and/or group of\n"
|
||||||
|
"the file named @var{name} in the directory referred to\n"
|
||||||
|
"by the file port @var{dir} instead. The optional argument\n"
|
||||||
|
"@var{flags} is a bitmask. If @code{AT_SYMLINK_NOFOLLOW} is\n"
|
||||||
|
"present, then @var{name} will not be dereferenced if it is a\n"
|
||||||
|
"symbolic link.")
|
||||||
|
#define FUNC_NAME s_scm_chownat
|
||||||
|
{
|
||||||
|
int rv;
|
||||||
|
int dir_fdes;
|
||||||
|
int c_flags;
|
||||||
|
|
||||||
|
if (SCM_UNBNDP (flags))
|
||||||
|
c_flags = 0;
|
||||||
|
else
|
||||||
|
c_flags = scm_to_int (flags);
|
||||||
|
|
||||||
|
SCM_VALIDATE_OPFPORT (SCM_ARG1, dir);
|
||||||
|
dir_fdes = SCM_FPORT_FDES (dir);
|
||||||
|
|
||||||
|
STRING_SYSCALL (name, c_name,
|
||||||
|
rv = fchownat (dir_fdes, c_name,
|
||||||
|
scm_to_int (owner), scm_to_int (group),
|
||||||
|
c_flags));
|
||||||
|
scm_remember_upto_here_1 (dir);
|
||||||
|
if (rv == -1)
|
||||||
|
SCM_SYSERROR;
|
||||||
|
return SCM_UNSPECIFIED;
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
#endif /* HAVE_FCHOWNAT */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SCM_DEFINE (scm_open_fdes, "open-fdes", 2, 1, 0,
|
SCM_DEFINE (scm_open_fdes, "open-fdes", 2, 1, 0,
|
||||||
|
|
|
@ -39,6 +39,7 @@ SCM_API scm_t_bits scm_tc16_dir;
|
||||||
|
|
||||||
|
|
||||||
SCM_API SCM scm_chown (SCM object, SCM owner, SCM group);
|
SCM_API SCM scm_chown (SCM object, SCM owner, SCM group);
|
||||||
|
SCM_API SCM scm_chownat (SCM dir, SCM object, SCM owner, SCM group, SCM flags);
|
||||||
SCM_API SCM scm_chmod (SCM object, SCM mode);
|
SCM_API SCM scm_chmod (SCM object, SCM mode);
|
||||||
SCM_API SCM scm_chmodat (SCM dir, SCM pathname, SCM mode, SCM flags);
|
SCM_API SCM scm_chmodat (SCM dir, SCM pathname, SCM mode, SCM flags);
|
||||||
SCM_API SCM scm_umask (SCM mode);
|
SCM_API SCM scm_umask (SCM mode);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue