news from the bleeding edge

Short and sweet information on bleeding edge AST features and future plans. The goal here is fodder for discussion and not deadlines. After an evaluation period these features will either become mainstream and documented or they will be eliminated.

SFIO_OPTIONS environment variable (implemented:2013-06-18)

The SFIO_OPTIONS environment variable value is a comma-separated list of [no]name[=value] options that control sfio defaults.

Overrides the SF_LINE default for SF_INIT streams. By default SF_LINE is applied to tty streams.

Controls the sfio memory mapping size hint. nomaxmap or maxmap=0 disables memory mapping and forces read(2), maxmap=-1 maps entire files, and maxmap=1Gi (or some other number) maps in 1Gib chunks.

Sets the maximum sfgetr(3) record size to size. A limit was added after an innocent sfgetr(3) brought a system to its knees when it tried to read a multi-Gib file that did not contain a single newline character. The default is currently unlimited (0).

Sets or clears mask bits in the internal sfio test mask _Sftest. Grep the sfio source for _Sftest to see if there are any active tests.

Overrides the SF_WCWIDTH default for all streams. By default SF_WCWIDTH is applied to tty streams.

pseudo device paths (implemented:2013-09-13)

Since 2006 ksh(1) has supported IP related pseudo devices for io redirection:


The handling of these and more have been moved to libast so that all commands and builtins have access to the pseudo devices in any pathname context. The format of device names containing @ were chosen carefully to be useable as fuse style filesystem mount points, and to allow both relative and absolute target path names. Some pseudo devices require features that may not be supported on all systems; on systems that do not support a required feature, path name accesses will fail with ENOTDIR or ENXIO depending on the path. Supported pseudo devices are:

The file corresponding to the open files descriptor fd in the current process. open(2) calls must match the read/write modes of fd. If fd is a directory or if the system supports openat(2) and O_XATTR then file descriptors returned by open(2) have a separate file table entry, i.e., the seek offset is independent of the seek offset of fd; otherwise a dup of fd is returned.

open(2) calls on the device will open path with the O_* flags corresponding to 1 or more of flag-i. path may be relative to the current directory (no leading /'s) or absolute (one or more leading /'s). The flags may be any combination of:






The extended attribute file attr-path for path, or the extended attributes directory of path if attr-path is omitted. path must be a /-canonical pathname; it may be relative to the current directory (no leading /'s) or absolute (one or more leading /'s).

The socket corresponding to the <protocol,host,port> tuple, where protocol may be one of sctp, tcp or udp, host may be an IPV4 or IPV6 raw address or a DNS host name, and port may be a raw port number or a port name supported by getservbyname(3).

Equivalent to /dev/fd/fd above.

If pid is the current process then this is equivalent to /dev/fd/fd above; otherwise the system must support /proc/pid/fd/fd to access fd in process pid.

ksh cd -@ (implemented:2013-09-13)

The ksh93 cd(1) builtin -@ option is present on all systems. cd exits with a diagnostic and non-zero exit status when
  • -@ is applied to a file or directory that does not have an extended attribute
  • -@ is applied on systems that support neither openat(2) nor the O_XATTR flag
The proper way to script a test for xattr files on a particular filesystem is to select a file from that filesystem and:
if ( cd -@ file-on-that-particular-filesystem ) 2>/dev/null
then	print xattr supported on that particular filesystem
else	print xattr not supported on that particular filesystem
Note that in general cd -@ can get a process into a situation where it can't determine or generate a path to the current working directory. However, this won't happen with ksh and any AST-compiled builtin or utility because the PWD environment variable will be a /dev/file/xattr@absolute-path//@// path. AST also properly handles /dev/file/xattr@absolute-path//@//.. so all directory traversal paradigms still work when xattr directories are in the mix.

September 13, 2013