[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 04/55: Define AT_SYMLINK_NOFOLLOW et al.
From: |
Andy Wingo |
Subject: |
[Guile-commits] 04/55: Define AT_SYMLINK_NOFOLLOW et al. |
Date: |
Thu, 23 May 2019 11:52:36 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 827e88b4b798b11013e8a9ef4e0f6ad111966321
Author: Ludovic Courtès <address@hidden>
Date: Sun Sep 23 16:39:42 2018 +0200
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.
---
doc/ref/posix.texi | 5 +++++
libguile/posix.c | 20 ++++++++++++++++++--
test-suite/tests/posix.test | 21 ++++++++++++++++++---
3 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 5cb68a2..1470e5f 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -801,6 +801,11 @@ systems.
@end lisp
will set the access time to one hour in the past and the
modification time to the current time.
+
address@hidden AT_SYMLINK_NOFOLLOW
+Last, @var{flags} may be either @code{0} or the
address@hidden constant, to set the time of
address@hidden even if it is a symbolic link.
@end deffn
@findex unlink
diff --git a/libguile/posix.c b/libguile/posix.c
index 2ad6c89..43e353e 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-2014,2016-2018
+/* Copyright 1995-2014,2016-2019
Free Software Foundation, Inc.
This file is part of Guile.
@@ -1626,7 +1626,10 @@ SCM_DEFINE (scm_utime, "utime", 1, 5, 0,
"(utime \"foo\" (- (current-time) 3600))\n"
"@end lisp\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
{
int rv;
@@ -2435,6 +2438,19 @@ scm_init_posix ()
scm_c_define ("LOCK_NB", scm_from_int (LOCK_NB));
#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 "posix.x"
diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index 1765206..aa1605a 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -1,7 +1,7 @@
;;;; posix.test --- Test suite for Guile POSIX functions. -*- scheme -*-
;;;;
-;;;; Copyright 2003, 2004, 2006, 2007, 2010, 2012,
-;;;; 2015, 2017, 2019 Free Software Foundation, Inc.
+;;;; Copyright 2003-2004,2006-2007,2010,2012,2015,2017-2019
+;;;; Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -181,7 +181,22 @@
(and (= (stat:atime info) accessed)
(= (stat:mtime info) modified)))))
(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
- [Guile-commits] 09/55: Gracefully handle huge shift counts in 'ash' and 'round-ash'., (continued)
- [Guile-commits] 09/55: Gracefully handle huge shift counts in 'ash' and 'round-ash'., Andy Wingo, 2019/05/23
- [Guile-commits] 24/55: SRFI-19: time-utc->date: Support non-integer nanoseconds values., Andy Wingo, 2019/05/23
- [Guile-commits] 21/55: SRFI-19: Add a few more tests., Andy Wingo, 2019/05/23
- [Guile-commits] 11/55: In 'ash' and 'round-ash', handle right shift count of LONG_MIN., Andy Wingo, 2019/05/23
- [Guile-commits] 16/55: Add tests for type inferencing for 'nil?' and 'null?' predicates., Andy Wingo, 2019/05/23
- [Guile-commits] 22/55: SRFI-19: Fix normalization of seconds and nanoseconds in time records., Andy Wingo, 2019/05/23
- [Guile-commits] 20/55: SRFI-19: Fix handling of negative years and negative julian days., Andy Wingo, 2019/05/23
- [Guile-commits] 37/55: Avoid leaking a file descriptor in test-unwind, Andy Wingo, 2019/05/23
- [Guile-commits] 38/55: Fix binary output on files created by mkstemp!, Andy Wingo, 2019/05/23
- [Guile-commits] 43/55: Fix typo in comment., Andy Wingo, 2019/05/23
- [Guile-commits] 04/55: Define AT_SYMLINK_NOFOLLOW et al.,
Andy Wingo <=
- [Guile-commits] 08/55: Fix list validation of *list->bytevector procedures., Andy Wingo, 2019/05/23
- [Guile-commits] 13/55: Update SRFI-19 leap second table., Andy Wingo, 2019/05/23
- [Guile-commits] 05/55: Fix 'atomic-box-compare-and-swap!'., Andy Wingo, 2019/05/23
- [Guile-commits] 26/55: Add texinfo dependency to README, Andy Wingo, 2019/05/23
- [Guile-commits] 27/55: Bootstrap optimization, Andy Wingo, 2019/05/23
- [Guile-commits] 32/55: Fix tests for SRFI-19 date->string ~N, Andy Wingo, 2019/05/23
- [Guile-commits] 33/55: Do not warn the user when 'madvise' returns ENOSYS., Andy Wingo, 2019/05/23
- [Guile-commits] 30/55: Update (ice-9 match) to include selected bug fixes from upstream., Andy Wingo, 2019/05/23
- [Guile-commits] 31/55: Support ~N in SRFI-19 string->date, Andy Wingo, 2019/05/23
- [Guile-commits] 28/55: Documentation fixes, Andy Wingo, 2019/05/23