|
110 | 110 | current mask that can be changed via a shell command \texttt{umask} -- those |
111 | 111 | bits in \emph{mode}, also set in the process umask, are nullified. The |
112 | 112 | default umask value is typically (and historically) \texttt{022}. We recommend |
113 | | -you to always se it to \texttt{077} in your profile script. Never do that for |
| 113 | +you to always set it to \texttt{077} in your profile script. Never do that for |
114 | 114 | root though otherwise you will end up with a system in a non-supported |
115 | 115 | configuration -- installed software will not be possible to run by |
116 | 116 | non-privileged users, what worked before may stop working, etc. |
|
192 | 192 | \begin{slide} |
193 | 193 | \sltitle{Reading and writing files: \texttt{read()}, \texttt{write()}} |
194 | 194 |
|
| 195 | +ifdef([[[NOSPELLCHECK]]], [[[ |
195 | 196 | \texttt{ssize\_t \funnm{read}(int \emph{fd}, void *\emph{buf}, |
196 | 197 | size\_t \emph{nbyte});} |
| 198 | +]]]) |
197 | 199 | \begin{itemize} |
198 | 200 | \item attempts to read \emph{nbyte} bytes of data from the object referenced by |
199 | 201 | the descriptor \emph{fd} into the buffer pointed to by \emph{buf} |
200 | 202 | \item returns the number of bytes actually read, 0 on EOF, -1 on error |
201 | 203 | \end{itemize} |
202 | 204 |
|
| 205 | +ifdef([[[NOSPELLCHECK]]], [[[ |
203 | 206 | \texttt{ssize\_t \funnm{write}(int \emph{fd}, const void *\emph{buf}, |
204 | 207 | size\_t \emph{nbyte});} |
| 208 | +]]]) |
205 | 209 | \begin{itemize} |
206 | 210 | \item attempts to write \emph{nbyte} of data to the object referenced by the |
207 | 211 | descriptor \emph{fd} from the buffer pointed to by \emph{buf} |
|
462 | 466 | \texttt{off\_t \funnm{lseek}(int \emph{fildes}, off\_t \emph{offset}, |
463 | 467 | int \emph{whence});} |
464 | 468 | \begin{itemize} |
465 | | -\item will reposition the file offset for reading and writing in an already |
| 469 | +\item will set the file offset for reading and writing in an already |
466 | 470 | opened file associated with a file descriptor \emph{fildes} |
467 | 471 | \item based on value of \texttt{whence}, the file offset is set to: |
468 | 472 | \begin{itemize} |
|
811 | 815 |
|
812 | 816 | \begin{slide} |
813 | 817 | \sltitle{Setting file times} |
814 | | -\texttt{int \funnm{utime}(const char *\emph{path}, const struct utimbuf *\emph{times});} |
| 818 | +ifdef([[[NOSPELLCHECK]]], [[[ |
| 819 | +\texttt{int \funnm{utime}(const char *\emph{path}, |
| 820 | +const struct utimbuf *\emph{times});} |
| 821 | +]]]) |
815 | 822 | \begin{itemize} |
816 | 823 | \item changes file last access and modification times |
817 | 824 | \item cannot change i-node access time (ctime) |
|
865 | 872 | \item \texttt{unlink} does not work on directories. |
866 | 873 | \item The shell command \texttt{mv} uses \texttt{rename} to move objects within |
867 | 874 | the same filesystems. To move files between filesystems, a file needs to be |
868 | | -copied first, then unlinked from the originating filesystem (the whole operation |
869 | | -is not atomic). |
| 875 | +copied first, then \texttt{unlink} it from the originating filesystem (the whole |
| 876 | +operation is not atomic). |
870 | 877 | \item \texttt{rename} renames symlinks, not the files those symlinks point to. |
871 | 878 | \item There is also a more generic call \texttt{remove}, see page |
872 | 879 | \pageref{REMOVE}. |
|
884 | 891 | \item make a new symbolic name from \emph{path2} $\rightarrow$ \emph{path1}. |
885 | 892 | \item \emph{path1} may span filesystems, and may not exist at all |
886 | 893 | \end{itemize} |
887 | | -\texttt{int \funnm{readlink}(const char *\emph{path}, char *\emph{buf}, size\_t \emph{bufsz});} |
| 894 | +ifdef([[[NOSPELLCHECK]]], [[[ |
| 895 | +\texttt{int \funnm{readlink}(const char *\emph{path}, char *\emph{buf}, |
| 896 | +size\_t \emph{bufsz});} |
| 897 | +]]]) |
888 | 898 | \begin{itemize} |
889 | | -\item put maximum of \texttt{\emph{bufsz}} bytes from the symlink target path to |
890 | | -\texttt{\emph{buf}} |
| 899 | +\item put maximum of \emph{\texttt{bufsz}} bytes from the symlink target path |
| 900 | +to \texttt{\emph{buf}} |
891 | 901 | \item returns the number of bytes written to \texttt{\emph{buf}}. |
892 | 902 | \item \texttt{\emph{buf}} is \emsl{not} terminated by \verb#'\0'# |
893 | 903 | \end{itemize} |
|
896 | 906 | \begin{itemize} |
897 | 907 | \item The shell command \texttt{ln} uses either the \texttt{symlink} or |
898 | 908 | \texttt{link} syscall depending on whether the \texttt{-s} option was used. |
899 | | -\item Unlinking a hardlink will not release the file data if other hardlinks |
900 | | -exists. You can delete the symlink's target in which case you end up with a |
901 | | -\emph{broken link}. |
| 909 | +\item Calling \texttt{unlink} on a hardlink will not release the file data if |
| 910 | +other hardlinks exists. You can delete the symlink's target in which case you |
| 911 | +end up with a \emph{broken link}. |
902 | 912 | \item \texttt{readlink} is useful in situation when you want to unlink the |
903 | 913 | symlink's target. |
904 | | -\item \texttt{\emph{bufsize}} is typically set as 1 byte less than the buffer |
905 | | -size to accommodate the terminating NUL character. |
| 914 | +\item \emph{\texttt{bufsize}} is typically set as 1 byte less than the buffer |
| 915 | +size to accommodate the terminating \texttt{NULL} character. |
906 | 916 | \end{itemize} |
907 | 917 |
|
908 | 918 | %%%%% |
|
920 | 930 | \begin{itemize} |
921 | 931 | \item deletes directory \emph{path}. The directory \emsl{must} be empty. |
922 | 932 | \end{itemize} |
| 933 | +ifdef([[[NOSPELLCHECK]]], [[[ |
923 | 934 | \texttt{DIR *\funnm{opendir}(const char *\emph{dirname});}\\ |
924 | 935 | \texttt{struct dirent *\funnm{readdir}(DIR *\emph{dirp});}\\ |
925 | 936 | \texttt{int \funnm{closedir}(DIR *\emph{dirp});} |
| 937 | +]]]) |
926 | 938 | \begin{itemize} |
927 | 939 | \item sequentially reads directory entries |
928 | 940 | \item structure \texttt{dirent} contains: |
929 | 941 | \begin{itemize} |
930 | | - \item \verb#d_ino# \dots{} i-node number |
931 | | - \item \verb#d_name# \dots{} file name |
| 942 | + \item \texttt{d\_ino} \dots{} i-node number |
| 943 | + \item \texttt{d\_name} \dots{} file name |
932 | 944 | \end{itemize} |
933 | 945 | \end{itemize} |
934 | 946 | \end{slide} |
|
1039 | 1051 |
|
1040 | 1052 | \begin{slide} |
1041 | 1053 | \sltitle{Check permissions for access: \texttt{access()}} |
| 1054 | +ifdef([[[NOSPELLCHECK]]], [[[ |
1042 | 1055 | \texttt{int \funnm{access}(const char *\emph{path}, int \emph{amode});} |
| 1056 | +]]]) |
1043 | 1057 | \begin{itemize} |
1044 | 1058 | \item checks whether the calling process can access the file \emph{path} |
1045 | | -\item \texttt{\emph{amode}} is an OR-combination of constants |
| 1059 | +\item \emph{\texttt{amode}} is an OR-combination of constants |
1046 | 1060 | \begin{itemize} |
1047 | 1061 | \item \verb#R_OK# \dots{} read permission test |
1048 | 1062 | \item \verb#W_OK# \dots{} write permission test |
|
0 commit comments