Home Contents | # rawio:statfs | Rawio | Core4 Lua Event System

## SYNOPSIS

1. stat = rawio.statfs(filename)
2. stat = rawio.statfs(fd)
3. stat = handle:statfs()

## DESCRIPTION

The functions return information about the file system where a given file or directory is stored. The first form takes a filename, the second uses an already open numeric file descriptor, while the third accesses an already open file handle.

## RETURN VALUE

On success, returns a table with the requested information. On failure, the forms one and two return three values: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library. Form three just returns nil on failure, the error can be retrieved using rawio:lastError().

Not all filesystem have usable values in all fields. Fields marked optional in the table below are not included in the returned table if the filesystem does not have that information.

Field | Contents
--- | ---
type | Type of file system. Example: "FAT"
blocksize | Size of one storage block.
blocks | Total number of blocks used by the file system.
blocks_free | Number of blocks that are free.
blocks_available | Number of blocks that are available for programs to store data.
files | Number of files and directories stored. | Optional
files_free | Free file nodes available. | Optional
fsid | Unique ID of this filesystem. | Optional
namelen | Max length of a filename. | Optional

## NOTES

To check if enough room is available for a new file, use the field blocks_available.

Do not naïvely multiply blocksize with blocks_free. For large media this may result in a number that would not fit into the 32-bit limit used by Core4 Lua.

## EXAMPLE

> >
st = rawio.statfs("/media/nv0") print(st.type)
FAT

## SEE ALSO

rawio.attach, rawio:blocking, rawio:canReadLine, rawio:clearError, rawio:close, rawio:connect, rawio:detach, rawio:lastError, rawio:line, rawio:lines, rawio.access, rawio.open, rawio:read, rawio:copy, rawio.stat, rawio:writet, rawio:writes, rawio:write