[squeak-dev] accessing file permissions within the image
David T. Lewis
lewis at mail.msen.com
Thu Jul 9 02:37:04 UTC 2015
On Wed, Jul 08, 2015 at 11:43:50PM +0200, Levente Uzonyi wrote:
>
> On Wed, 8 Jul 2015, Chris Muller wrote:
> >
> >Is it possible to determine the Linux file permissions of a file or
> >directory from within the image running on Linux?
> >
>
> IIRC the Pharo guys have added that feature to their version of
> FilePlugin.
>
OSProcess accessor fileStat: '/etc/hosts' ==> #(0 0 #(0 6 4 4))
The primitive is in UnixOSProcessPlugin, and is accessed like this:
UnixOSProcessAccessor>>primFileStat: aPathString
"Call stat(2) to obtain the file protection mask for a file. Answer errno on failure,
or on success answer an array with: UID with: GID with: protectionMask. The
protectionMask is an Array of four integers representing the protection mask, or
answer errno on failure. The protection mask is four Integers, each of which may
be considered an octal digit (0-7), with bit values 4, 2, and 1. The first digit selects
the set user ID (4) and set group ID (2) and save text image (1) attributes. The second
digit selects permissions for the user who owns the file: read (4), write (2), and
execute (1); the third selects permissions for other users in the file's group, with
the same values; and the fourth for other users not in the file's group, with the
same values."
<primitive: 'primitiveFileStat' module: 'UnixOSProcessPlugin'>
^ nil
Dave
More information about the Squeak-dev
mailing list
|