1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-28 16:00:22 +02:00

Define AT_SYMLINK_NOFOLLOW et al.

* libguile/posix.c (scm_init_posix): Define AT_SYMLINK_NOFOLLOW,
AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, and AT_EMPTY_PATH when available.
(scm_utime): Mention AT_SYMLINK_NOFOLLOW.
* doc/ref/posix.texi (File System): Update accordingly.
* test-suite/tests/posix.test ("utime")["AT_SYMLINK_NOFOLLOW"]: New test.
This commit is contained in:
Ludovic Courtès 2018-09-23 16:39:42 +02:00 committed by Andy Wingo
parent 176bfd0bce
commit 827e88b4b7
3 changed files with 41 additions and 5 deletions

View file

@ -801,6 +801,11 @@ systems.
@end lisp @end lisp
will set the access time to one hour in the past and the will set the access time to one hour in the past and the
modification time to the current time. modification time to the current time.
@vindex AT_SYMLINK_NOFOLLOW
Last, @var{flags} may be either @code{0} or the
@code{AT_SYMLINK_NOFOLLOW} constant, to set the time of
@var{pathname} even if it is a symbolic link.
@end deffn @end deffn
@findex unlink @findex unlink

View file

@ -1,4 +1,4 @@
/* Copyright 1995-2014,2016-2018 /* Copyright 1995-2014,2016-2019
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of Guile. This file is part of Guile.
@ -1626,7 +1626,10 @@ SCM_DEFINE (scm_utime, "utime", 1, 5, 0,
"(utime \"foo\" (- (current-time) 3600))\n" "(utime \"foo\" (- (current-time) 3600))\n"
"@end lisp\n" "@end lisp\n"
"will set the access time to one hour in the past and the\n" "will set the access time to one hour in the past and the\n"
"modification time to the current time.") "modification time to the current time.\n\n"
"Last, @var{flags} may be either @code{0} or the\n"
"@code{AT_SYMLINK_NOFOLLOW} constant, to set the time of\n"
"@var{pathname} even if it is a symbolic link.\n")
#define FUNC_NAME s_scm_utime #define FUNC_NAME s_scm_utime
{ {
int rv; int rv;
@ -2435,6 +2438,19 @@ scm_init_posix ()
scm_c_define ("LOCK_NB", scm_from_int (LOCK_NB)); scm_c_define ("LOCK_NB", scm_from_int (LOCK_NB));
#endif #endif
#ifdef AT_SYMLINK_NOFOLLOW
scm_c_define ("AT_SYMLINK_NOFOLLOW", scm_from_int (AT_SYMLINK_NOFOLLOW));
#endif
#ifdef AT_SYMLINK_FOLLOW
scm_c_define ("AT_SYMLINK_FOLLOW", scm_from_int (AT_SYMLINK_FOLLOW));
#endif
#ifdef AT_NO_AUTOMOUNT
scm_c_define ("AT_NO_AUTOMOUNT", scm_from_int (AT_NO_AUTOMOUNT));
#endif
#ifdef AT_EMPTY_PATH
scm_c_define ("AT_EMPTY_PATH", scm_from_int (AT_EMPTY_PATH));
#endif
#include "cpp-SIG.c" #include "cpp-SIG.c"
#include "posix.x" #include "posix.x"

View file

@ -1,7 +1,7 @@
;;;; posix.test --- Test suite for Guile POSIX functions. -*- scheme -*- ;;;; posix.test --- Test suite for Guile POSIX functions. -*- scheme -*-
;;;; ;;;;
;;;; Copyright 2003, 2004, 2006, 2007, 2010, 2012, ;;;; Copyright 2003-2004,2006-2007,2010,2012,2015,2017-2019
;;;; 2015, 2017, 2019 Free Software Foundation, Inc. ;;;; Free Software Foundation, Inc.
;;;; ;;;;
;;;; This library is free software; you can redistribute it and/or ;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public ;;;; modify it under the terms of the GNU Lesser General Public
@ -181,7 +181,22 @@
(and (= (stat:atime info) accessed) (and (= (stat:atime info) accessed)
(= (stat:mtime info) modified))))) (= (stat:mtime info) modified)))))
(lambda () (lambda ()
(delete-file file)))))) (delete-file file)))))
(pass-if-equal "AT_SYMLINK_NOFOLLOW"
'(1 1)
(if (defined? 'AT_SYMLINK_NOFOLLOW)
(let ((file "posix.test-utime"))
(dynamic-wind
(lambda ()
(symlink "/dev/null" file))
(lambda ()
(utime file 1 1 0 0 AT_SYMLINK_NOFOLLOW)
(let ((info (lstat file)))
(list (stat:atime info) (stat:mtime info))))
(lambda ()
(delete-file file))))
(throw 'unsupported))))
;; ;;
;; affinity ;; affinity