develooper Front page | perl.perl5.porters | Postings from July 2017

Can the POSIX *at functions be supported in Perl?

Thread Next
From:
James E Keenan
Date:
July 27, 2017 23:19
Subject:
Can the POSIX *at functions be supported in Perl?
Message ID:
20170727231854.5255.qmail@lists-nntp.develooper.com
In the past few days I've had conversations with John Lightsey and
Mark Overmeer which have drawn my attention to the set of POSIX
interfaces originally proposed in 2006 in "Extended API Set Part 2"
(http://www.opengroup.org/onlinepubs/9699939699/toc.pdf).  As
described in a posting on lwn.net in that year
(https://lwn.net/Articles/172675/),

#####

The set of interfaces includes:

faccessat()
fchmodat()
fchownat()
fdopendir()
fexecve()
fstatat()
futimesat()
linkat()
mkdirat()
mkfifoat()
mknodat()
openat()
readlinkat()
renameat()
symlinkat()
unlinkat()

The motivation for the introduction of this set of interfaces is as
follows:

* Interfaces taking a path name are limited by the maximum length of a
path name(_SC_PATH_MAX). The absolute path of files can far exceed
this length. The current solution would be to change the working
directory and use relative path names. This is not thread-safe.

* A second motivation is that files accessed outside the current working
directory are subject to attacks caused by the race condition created
by change any of the elements ofthe path names used.

* A third motivation is to allow implementing code which uses a virtual
current working directory for each individual thread. In the current
model there is only one current working directory for all threads.

The new interfaces solve these issues by duplicating existing
interfaces using path names with one change, that is an additional
parameter. This additional parameter must be a file descriptor for a
directory. The operations will then work relative to the specified
directory instead of the current working directory whenever the later
would be accessed.  I can see the usefulness of the second motivation
cited above for functionality that traverses the filesystem, such as
File-Path and File-Find.

One CPAN distribution, POSIX-2008,
(http://search.cpan.org/~cgpan/POSIX-2008-0.04/) mentions the *at
functions but disclaims ongoing maintenance.  Another CPAN
distribution, POSIX-1003-0.98
(http://search.cpan.org/~markov/POSIX-1003-0.98/) is well maintained,
but its documentation states, "None of the functions of the 'at'
interface is supported".

Could these interfaces be implemented in the Perl 5 core?

Should they?

Thank you very much.
Jim Keenan

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About