# 22. Virtuoso Functions Guide - os_chmod

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
file_delete
file_dirlist
file_mkdir
file_mkpath
file_stat
file_to_string
file_to_string_outpu...
file_unlink
os_chmod
os_chown
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## os_chmod

changes the file access mode of a file
os_chmod (in path varchar, in new_mod integer);
Parameters
path – varchar relative path.
new_mod – integer new mode for the file.
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 succsessfully 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.

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

See Also

file_delete

file_stat

os_chown

virtuoso_ini_path

bit_or

bit_xor