Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb3b002

Browse files
committed
Patches describing the statvfs() and fstatvfs() functions. Additional
text about large file support. All new text by Steve Clift <[email protected]>, with only minor revision / addition of markup.
1 parent 583b019 commit bb3b002

1 file changed

Lines changed: 68 additions & 16 deletions

File tree

Doc/lib/libposix.tex

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ \section{\module{posix} ---
22
The most common \POSIX{} system calls.}
33
\declaremodule{builtin}{posix}
44

5-
\modulesynopsis{The most common \POSIX{} system calls (normally used via module
6-
\module{os}).}
5+
\modulesynopsis{The most common \POSIX{} system calls (normally used
6+
via module \module{os}).}
77

88

99
This module provides access to operating system functionality that is
@@ -17,10 +17,9 @@ \section{\module{posix} ---
1717
\module{posix} module is not available, but a subset is always
1818
available through the \module{os} interface. Once \module{os} is
1919
imported, there is \emph{no} performance penalty in using it instead
20-
of \module{posix}. In addition, \module{os} provides some additional
21-
functionality, such as automatically calling \function{putenv()}
22-
when an entry in \code{os.environ} is changed.
23-
\refstmodindex{os}
20+
of \module{posix}. In addition, \module{os}\refstmodindex{os}
21+
provides some additional functionality, such as automatically calling
22+
\function{putenv()} when an entry in \code{os.environ} is changed.
2423

2524
The descriptions below are very terse; refer to the corresponding
2625
\UNIX{} manual (or \POSIX{} documentation) entry for more information.
@@ -29,19 +28,45 @@ \section{\module{posix} ---
2928
Errors are reported as exceptions; the usual exceptions are given for
3029
type errors, while errors reported by the system calls raise
3130
\exception{error} (a synonym for the standard exception
32-
\exception{OSError}), described
33-
below.
31+
\exception{OSError}), described below.
32+
33+
\subsection{Large File Support \label{posix-large-files}}
34+
\index{large files}
35+
\index{file!large files}
36+
37+
\sectionauthor{Steve Clift}{[email protected]}
38+
39+
Several operating systems (including AIX, HPUX, Irix and Solaris)
40+
provide support for files that are larger than 2 Gb from a \C{}
41+
programming model where \ctype{int} and \ctype{long} are 32-bit
42+
values. This is typically accomplished by defining the relevant size
43+
and offset types as 64-bit values. Such files are sometimes referred
44+
to as \dfn{large files}.
45+
46+
Large file support is enabled in Python when the size of an
47+
\ctype{off_t} is larger than a \ctype{long} and the \ctype{long long}
48+
type is available and is at least as large as an \ctype{off_t}. Python
49+
longs are then used to represent file sizes, offsets and other values
50+
that can exceed the range of a Python int. It may be necessary to
51+
configure and compile Python with certain compiler flags to enable
52+
this mode. For example, it is enabled by default with recent versions
53+
of Irix, but with Solaris 2.6 and 2.7 you need to do something like:
54+
55+
\begin{verbatim}
56+
CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" OPT="-g -O2 $CFLAGS" \
57+
configure
58+
\end{verbatim} % $ <-- bow to font-lock
59+
60+
61+
\subsection{\module{posix} Module Contents \label{posix-contents}}
3462

3563
Module \module{posix} defines the following data items:
3664

3765
\begin{datadesc}{environ}
3866
A dictionary or dictionary look-alike representing the string
39-
environment at the time the interpreter was started.
40-
For example,
41-
\code{posix.environ['HOME']}
42-
is the pathname of your home directory, equivalent to
43-
\code{getenv("HOME")}
44-
in \C{}.
67+
environment at the time the interpreter was started. For example,
68+
\code{posix.environ['HOME']} is the pathname of your home directory,
69+
equivalent to \code{getenv("HOME")} in \C{}.
4570

4671
Modifying this dictionary does not affect the string environment
4772
passed on by \function{execv()}, \function{popen()} or
@@ -78,7 +103,8 @@ \section{\module{posix} ---
78103
\code{'OSError'}.
79104
\end{excdesc}
80105

81-
It defines the following functions and constants:
106+
It defines the following functions and constants when the operating
107+
system provides them directly or provides the means to emulate them:
82108

83109
\begin{funcdesc}{access}{path, mode}
84110
Check read/write/execute permissions for this process or extance of file
@@ -161,6 +187,11 @@ \section{\module{posix} ---
161187
Return status for file descriptor \var{fd}, like \function{stat()}.
162188
\end{funcdesc}
163189

190+
\begin{funcdesc}{fstatvfs}{fd}
191+
Return information about the filesystem containing the file associated
192+
with file descriptor \var{fd}, like \function{statvfs()}.
193+
\end{funcdesc}
194+
164195
\begin{funcdesc}{ftruncate}{fd, length}
165196
Truncate the file corresponding to file descriptor \var{fd},
166197
so that it is at most \var{length} bytes in size.
@@ -414,7 +445,28 @@ \section{\module{posix} ---
414445

415446
Note: The standard module \module{stat}\refstmodindex{stat} defines
416447
functions and constants that are useful for extracting information
417-
from a stat structure.
448+
from a \ctype{stat} structure.
449+
\end{funcdesc}
450+
451+
\begin{funcdesc}{statvfs}{path}
452+
Perform a \cfunction{statvfs()} system call on the given path. The
453+
return value is a tuple of 11 integers giving the most common
454+
members of the \ctype{statvfs} structure, in the order
455+
\code{f_bsize},
456+
\code{f_frsize},
457+
\code{f_blocks},
458+
\code{f_bfree},
459+
\code{f_bavail},
460+
\code{f_files},
461+
\code{f_ffree},
462+
\code{f_favail},
463+
\code{f_fsid},
464+
\code{f_flag},
465+
\code{f_namemax}.
466+
467+
Note: The standard module \module{statvfs}\refstmodindex{statvfs}
468+
defines constants that are useful for extracting information
469+
from a \ctype{statvfs} structure.
418470
\end{funcdesc}
419471

420472
\begin{funcdesc}{symlink}{src, dst}

0 commit comments

Comments
 (0)