summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ftw.c2
-rw-r--r--socket.c4
-rw-r--r--sysif.c19
-rw-r--r--sysif.h4
-rw-r--r--txr.126
5 files changed, 40 insertions, 15 deletions
diff --git a/ftw.c b/ftw.c
index 9f3109dc..346b0655 100644
--- a/ftw.c
+++ b/ftw.c
@@ -61,7 +61,7 @@ static int ftw_callback(const char *c_path, const struct stat *c_sb,
{
val path = string_utf8(c_path);
val type = num(c_type);
- val sb = stat_to_struct(*c_sb);
+ val sb = stat_to_struct(*c_sb, path);
val level = num(fb->level);
val base = num(fb->base);
val result;
diff --git a/socket.c b/socket.c
index 5ecaa78c..aca7240c 100644
--- a/socket.c
+++ b/socket.c
@@ -50,6 +50,7 @@
#include "args.h"
#include "struct.h"
#include "arith.h"
+#include "sysif.h"
#include "socket.h"
#define MIN(A, B) ((A) < (B) ? (A) : (B))
@@ -76,7 +77,7 @@ struct dgram_stream {
val sockaddr_in_s, sockaddr_in6_s, sockaddr_un_s, addrinfo_s;
val flags_s, family_s, socktype_s, protocol_s, addr_s, canonname_s;
-val port_s, flow_info_s, scope_id_s, path_s;
+val port_s, flow_info_s, scope_id_s;
static val ipv4_addr_to_num(struct in_addr *src)
{
@@ -1073,7 +1074,6 @@ void sock_load_init(void)
port_s = intern(lit("port"), user_package);
flow_info_s = intern(lit("flow-info"), user_package);
scope_id_s = intern(lit("scope-id"), user_package);
- path_s = intern(lit("path"), user_package);
#ifdef HAVE_GETADDRINFO
reg_fun(intern(lit("getaddrinfo"), user_package), func_n3o(getaddrinfo_wrap, 1));
diff --git a/sysif.c b/sysif.c
index d19c041d..0e104851 100644
--- a/sysif.c
+++ b/sysif.c
@@ -92,7 +92,7 @@ val gid_k, rdev_k, size_k, blksize_k, blocks_k;
val atime_k, mtime_k, ctime_k;
val dev_s, ino_s, mode_s, nlink_s, uid_s;
val gid_s, rdev_s, size_s, blksize_s, blocks_s;
-val atime_s, mtime_s, ctime_s;
+val atime_s, mtime_s, ctime_s, path_s;
#if HAVE_PWUID
val passwd_s, gecos_s, dir_s, shell_s;
@@ -654,7 +654,7 @@ static val stat_to_list(struct stat st)
nao);
}
-val stat_to_struct(struct stat st)
+val stat_to_struct(struct stat st, val path)
{
args_decl(args, ARGS_MIN);
val strct = make_struct(stat_s, nil, args);
@@ -676,13 +676,15 @@ val stat_to_struct(struct stat st)
slotset(strct, atime_s, num(st.st_atime));
slotset(strct, mtime_s, num(st.st_mtime));
slotset(strct, ctime_s, num(st.st_ctime));
+ if (path)
+ slotset(strct, path_s, path);
return strct;
}
#endif
static val stat_impl(val obj, int (*statfn)(val, struct stat *),
- val name)
+ val name, val path)
{
#if HAVE_SYS_STAT
struct stat st;
@@ -693,7 +695,7 @@ static val stat_impl(val obj, int (*statfn)(val, struct stat *),
name, obj, num(errno), string_utf8(strerror(errno)), nao);
return if3(opt_compat && opt_compat <= 113,
- stat_to_list(st), stat_to_struct(st));
+ stat_to_list(st), stat_to_struct(st, path));
#else
uw_throwf(file_error_s, lit("~a is not implemented"), name, nao);
#endif
@@ -701,17 +703,17 @@ static val stat_impl(val obj, int (*statfn)(val, struct stat *),
val statp(val path)
{
- return stat_impl(path, w_stat, lit("stat"));
+ return stat_impl(path, w_stat, lit("stat"), path);
}
static val statl(val path)
{
- return stat_impl(path, w_lstat, lit("lstat"));
+ return stat_impl(path, w_lstat, lit("lstat"), path);
}
val statf(val stream)
{
- return stat_impl(stream, w_fstat, lit("fstat"));
+ return stat_impl(stream, w_fstat, lit("fstat"), nil);
}
#if HAVE_SYS_STAT
@@ -1483,6 +1485,7 @@ void sysif_init(void)
atime_s = intern(lit("atime"), user_package);
mtime_s = intern(lit("mtime"), user_package);
ctime_s = intern(lit("ctime"), user_package);
+ path_s = intern(lit("path"), user_package);
#if HAVE_PWUID
passwd_s = intern(lit("passwd"), user_package);
gecos_s = intern(lit("gecos"), user_package);
@@ -1506,7 +1509,7 @@ void sysif_init(void)
make_struct_type(stat_s, nil, nil,
list(dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s,
rdev_s, size_s, blksize_s, blocks_s, atime_s,
- mtime_s, ctime_s, nao), nil, nil, nil, nil);
+ mtime_s, ctime_s, path_s, nao), nil, nil, nil, nil);
#if HAVE_PWUID
make_struct_type(passwd_s, nil, nil,
list(name_s, passwd_s, uid_s, gid_s,
diff --git a/sysif.h b/sysif.h
index f32c3f9b..c3a29ccc 100644
--- a/sysif.h
+++ b/sysif.h
@@ -31,7 +31,7 @@ extern val gid_k, rdev_k, size_k, blksize_k, blocks_k;
extern val atime_k, mtime_k, ctime_k;
extern val dev_s, ino_s, mode_s, nlink_s, uid_s;
extern val gid_s, rdev_s, size_s, blksize_s, blocks_s;
-extern val atime_s, mtime_s, ctime_s;
+extern val atime_s, mtime_s, ctime_s, path_s;
#if !HAVE_FTRUNCATE
typedef long off_t;
@@ -52,7 +52,7 @@ val exec_wrap(val file, val args_opt);
#endif
#if HAVE_SYS_STAT
struct stat;
-val stat_to_struct(struct stat st);
+val stat_to_struct(struct stat st, val path);
#endif
val statp(val path);
val statf(val path);
diff --git a/txr.1 b/txr.1
index 3db58b24..efbad32f 100644
--- a/txr.1
+++ b/txr.1
@@ -46646,7 +46646,7 @@ as a way of specifying a command to execute.
.mets (defstruct stat nil
.mets \ \ dev ino mod nlink uid gid
.mets \ \ rdev size blksize blocks atime
-.mets \ \ mtime ctime)
+.mets \ \ mtime ctime path)
.syne
.desc
The
@@ -46657,13 +46657,24 @@ by the
.codn lstat ,
and
.code fstat
-functions. The slots are the direct counterparts of the
+functions. Except for
+.codn path ,
+the slots are the direct counterparts of the
members of POSIX C structure
.codn "struct stat" .
For instance the slot
.code dev
corresponds to
.codn st_dev .
+The
+.code path
+slot is set by the functions
+.code stat
+and
+.codn lstat .
+Its value is
+.code nil
+when the path is not available.
.coNP Functions @, stat @ lstat and @ fstat
.synb
@@ -46710,6 +46721,17 @@ function can retrieve a file descriptor, otherwise an exception of type
.code file-error
is thrown.
+The
+.code path
+slot of the returned structure
+holds a copy of their
+.meta path
+argument value.
+In the case of
+.codn fstat ,
+this slot is
+.codn nil .
+
.coNP Variables @, s-ifmt @, s-iflnk @, s-ifreg @, s-ifblk ... , @ s-ixoth
.desc
The following variables exist, having integer values. These are bitmasks