os_chmod
changes the file access mode of a file
os_chmod
(in path varchar,
in new_mod integer);
Description
os_chmod set the file mode bits
by calling the system function chmod() with the arguments supplied.
Not all the host OSes support all the file modes. That's why the function
will not throw an SQL error if the function fails.
It will return DB NULL value when the function was called successfully
and the error message as a string if it failed.
In most OSes the mode is a bitmask, so one would usually use the
file_stat to get the current mode and
bit_or/bit_xor to make the new
mode.
Typical bit layout (from Linux 'man 2 chmod') is :
- bit 0 (mask 1) - execute/search by others
- bit 1 (mask 2) - write by others
- bit 2 (mask 4) - read by others
- bit 3 (mask 8) - execute/search by group
- bit 4 (mask 16) - write by group
- bit 5 (mask 32) - read by group
- bit 6 (mask 64) - execute/search by owner
- bit 7 (mask 128) - write by owner
- bit 8 (mask 256) - read by owner
- bit 9 (mask 512) - sticky bit
- bit 10 (mask 1024) - set group ID on execution
- bit 12 (mask 2048) - set user ID on execution
The DirsAllowed and DirsDenied lists in Parameters section of the
virtuoso configuration file (virtuoso.ini by default) are used to control
disk access.
Parameters
path –
varchar relative path.
new_mod –
integer new mode for the file.
Examples
Simple example
Make the virtuoso INI file readable by the others
SQL>select os_chmod (virtuoso_ini_path(), bit_or (cast (file_stat (virtuoso_ini_path(), 2) as integer), 4));
callret
VARCHAR
_______________________________________________________________________________
NULL