v/vlib/os
2025-09-05 12:50:30 +03:00
..
asset builtin,os: enable no warnings for gg programs like v -gc boehm_leak -cg -keepc run examples/gg/minimal.v (part 1 - before the gg loop) (#24749) 2025-06-18 16:37:57 +03:00
bare parser, ast, fmt: convert "hello".str => c"hello" (fix #24635) (#24652) 2025-06-08 11:44:38 +03:00
cmdline
filelock os.filelock: compile without warnings with gcc on windows 2025-04-23 07:52:07 +03:00
font os.font: fixes for -os android 2025-06-18 16:38:40 +03:00
notify docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
util all: vls mode fixes and improvements; v -json-errors flag 2025-08-10 06:45:59 +03:00
args.v
const.v
const_nix.c.v
const_windows.c.v
debugger_darwin.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
debugger_default.c.v os: improve documentation (#24790) 2025-06-25 22:29:47 +03:00
debugger_freebsd.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
debugger_linux.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
debugger_openbsd.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
debugger_windows.c.v
dir_expansions_test.v
environment.c.v os: fix documentation for environ function (#24796) 2025-06-26 19:25:02 +03:00
environment.js.v
environment_test.v
fd.c.v
file.c.v os: simplify file.c.v using cross platform f.seek/2 calls, add EINTR handling to f.write_full_buffer/2 (fix #25107) (#25110) 2025-08-15 08:02:34 +03:00
file.js.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
file_buffering.c.v
file_buffering_test.v
file_le_be.c.v os: fix swap_bytes_u64 (#24033) 2025-03-25 15:34:57 +02:00
file_le_be_test.v os: fix swap_bytes_u64 (#24033) 2025-03-25 15:34:57 +02:00
file_test.v os: fix os.File's tell/0 method for windows (fix #24217) (#24218) 2025-05-20 15:41:15 +03:00
filepath.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
filepath_test.v
filepath_windows.v
find_abs_path_of_executable_test.v os: do not resolve symlinks in os.find_abs_path_of_executable/1 (fix #24759) (#24761) 2025-06-24 02:53:13 +03:00
glob_test.v
inode.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
inode_test.v
join_path_test.v
open_and_read_from_file_test.js.v tools: cleanup entries from the hardcoded skip_files list in common.v (used by v test, v test-self etc); use the new // vtest build: syntax to mark the tests instead (#23918) 2025-03-13 19:51:51 +02:00
open_uri_default.c.v
open_uri_windows.c.v
os.c.v os,ci: use a conditional include, instead of a platform file, to include libproc.h on macos only 2025-09-05 12:50:30 +03:00
os.js.v
os.v os: remove commented code in home_dir() function (#24929) 2025-07-20 06:20:56 +03:00
os_android_outside_termux.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
os_darwin.c.v os,ci: use a conditional include, instead of a platform file, to include libproc.h on macos only 2025-09-05 12:50:30 +03:00
os_js.js.v
os_linux.c.v
os_nix.c.v all: vls mode fixes and improvements; v -json-errors flag 2025-08-10 06:45:59 +03:00
os_stat_default.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
os_stat_test.v
os_stat_windows.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
os_structs_dirent_default.c.v
os_structs_sigaction_default.c.v
os_structs_stat_default.c.v
os_structs_stat_linux.c.v
os_structs_stat_windows.c.v
os_structs_utsname_default.c.v
os_test.c.v os: add os.write_bytes/2 as a complement to os.read_bytes/1, add test 2025-06-28 09:27:09 +03:00
os_windows.c.v os,sync: enable running v -cross -o x.c cmd/v on windows too (part 1, fix V errors) 2025-08-26 18:09:53 +03:00
password_nix.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
password_windows.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
process.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
process.js.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
process.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
process_nix.c.v os: implement Process.is_pending() on windows (fix #23990) (#23993) 2025-03-21 11:03:03 +02:00
process_test.v os,tools: make easier analyzing process_test.v failures on the CI 2025-03-26 14:00:47 +02:00
process_windows.c.v checker: do not allow &u8(0), force nil like we do with &Type(0) 2025-05-03 22:37:51 +03:00
README.md
signal.c.v docs,ci: check more vlib modules in the report-missing-dots-in-doc-comments job (#24928) 2025-07-19 11:51:01 +03:00
signal.js.v
signal.v
signal_darwin.c.v
signal_default.c.v
signal_linux.c.v
signal_test.v
signal_windows.c.v
sleeping.c.v
sleeping.js.v
xdg_test.v

Description

os provides common OS/platform independent functions for accessing command line arguments, reading/writing files, listing folders, handling processes etc.


A few os module functions can lead to the TOCTOU vulnerability if used incorrectly. TOCTOU (Time-of-Check-to-Time-of-Use problem) can occur when a file, folder or similar is checked for certain specifications (e.g. read, write permissions) and a change is made afterwards. In the time between the initial check and the edit, an attacker can then cause damage. The following example shows an attack strategy on the left and an improved variant on the right so that TOCTOU is no longer possible.

Example
Hint: os.create() opens a file in write-only mode

Possibility for TOCTOU attack TOCTOU not possible
if os.is_writable("file") {
    // time to make a quick attack
    // (e.g. symlink /etc/passwd to `file`)

    mut f := os.create('path/to/file')!
    // do something with file
    f.close()
}
mut f := os.create('path/to/file') or {
    println("file not writable")
}

// file is locked
// do something with file

f.close()

Proven affected functions
The following functions should be used with care and only when used correctly.

  • os.is_readable()
  • os.is_writable()
  • os.is_executable()
  • os.is_link()