|
434 | 434 | \item All the information here applies to a unnamed pipes as well, see page |
435 | 435 | \pageref{PIPE}. |
436 | 436 |
|
437 | | -%%%\item pro zápis platí toto (pøevzato z [Rochkind]): |
| 437 | +%%%\item pro zápis platí toto (pøevzato z [Rochkind]): |
438 | 438 | %%% |
439 | 439 | %%%\renewcommand{\arraystretch}{1.3} |
440 | 440 | %%% |
441 | 441 | %%%\begin{tabularx}{1.0\textwidth}{|l|l|l|l|l|} |
442 | 442 | %%%\hline |
443 | | -%%%\texttt{O\_NONBLOCK} ? & bajtù k zápisu & nic nelze zapsat & èásteèný zápis |
444 | | -%%%mo¾ný & kompletní zápis mo¾ný \\ |
| 443 | +%%%\texttt{O\_NONBLOCK} ? & bajtù k zápisu & nic nelze zapsat & èásteèný zápis |
| 444 | +%%%mo¾ný & kompletní zápis mo¾ný \\ |
445 | 445 | %%%\hline |
446 | | -%%%není & \texttt{<= PIPE\_BUF} & zablokuje se; kompletní zápis; atomické & |
447 | | -%%%zablokuje se; kompletní zápis; atomické & nezablokuje se; kompletní zápis; |
448 | | -%%%atomické \\ |
| 446 | +%%%není & \texttt{<= PIPE\_BUF} & zablokuje se; kompletní zápis; atomické & |
| 447 | +%%%zablokuje se; kompletní zápis; atomické & nezablokuje se; kompletní zápis; |
| 448 | +%%%atomické \\ |
449 | 449 | %%%\hline |
450 | | -%%%není & \texttt{> PIPE\_BUF} & zablokuje se; kompletní zápis; není atomické & |
451 | | -%%%zablokuje se; kompletní zápis; není atomické & mù¾e se zablokovat; kompletní |
452 | | -%%%zápis; není atomické \\ |
| 450 | +%%%není & \texttt{> PIPE\_BUF} & zablokuje se; kompletní zápis; není atomické & |
| 451 | +%%%zablokuje se; kompletní zápis; není atomické & mù¾e se zablokovat; kompletní |
| 452 | +%%%zápis; není atomické \\ |
453 | 453 | %%%\hline |
454 | 454 | %%%nastaven & \texttt{<= PIPE\_BUF} & \texttt{EAGAIN} & \texttt{EAGAIN} & |
455 | | -%%%nezablokuje se; kompletní zápis; atomické \\ |
| 455 | +%%%nezablokuje se; kompletní zápis; atomické \\ |
456 | 456 | %%%\hline |
457 | | -%%%nastaven & \texttt{> PIPE\_BUF} & \texttt{EAGAIN} & nezablokuje se; èásteèný |
458 | | -%%%zápis nebo \texttt{EAGAIN}; není atomické & nezablokuje se; kompletní, |
459 | | -%%%èásteèný zápis nebo \texttt{EAGAIN}; není atomické \\ |
| 457 | +%%%nastaven & \texttt{> PIPE\_BUF} & \texttt{EAGAIN} & nezablokuje se; èásteèný |
| 458 | +%%%zápis nebo \texttt{EAGAIN}; není atomické & nezablokuje se; kompletní, |
| 459 | +%%%èásteèný zápis nebo \texttt{EAGAIN}; není atomické \\ |
460 | 460 | %%%\hline |
461 | 461 | %%%\end{tabularx} |
462 | 462 | \end{itemize} |
|
775 | 775 | \item The UNIX norm does not specify the ordering of the \texttt{struct stat} |
776 | 776 | members, nor does it prohibit adding new ones. |
777 | 777 | \item \label{STAT} Example: \example{stat/stat.c} |
778 | | -\item You can call \texttt{fstat} on file descriptors 0,1,2 as well. Unless |
| 778 | +\item You can call \texttt{fstat} on file descriptors 0, 1, and 2 as well. Unless |
779 | 779 | redirected before, you will get information on the underlying terminal device |
780 | 780 | (e.g. \texttt{/dev/ttys011} on macOS). Example: \example{stat/stat012.c}. |
781 | 781 | \end{itemize} |
|
791 | 791 | \item for a file type, in \texttt{<sys/stat.h>} there are |
792 | 792 | constants \verb#S_IFMT# (bit mask for the file type bit field), \verb#S_IFBLK# |
793 | 793 | (block device), \verb#S_IFCHR# (character device), \verb#S_IFIFO# |
794 | | -(FIFO), \verb#S_IFREG# (regular), \verb#S_IFDIR# (directory), |
| 794 | +(FIFO), \verb#S_IFREG# (regular), \verb#S_IFDIR# (directory), and |
795 | 795 | \verb#S_IFLNK# (symlink). |
796 | 796 | \item macros for file type checking: \verb#S_ISBLK(m)#, |
797 | 797 | \verb#S_ISCHR(m)#, \verb#S_ISFIFO(m)#, \verb#S_ISREG(m)#, |
|
804 | 804 | *\emph{buf});} |
805 | 805 | ]]]) |
806 | 806 | \begin{itemize} |
807 | | -\item if \emph{path} is a symlink, \texttt{stat()} returns information of the |
808 | | -file the symlink refers to. This function returns information about the link |
| 807 | +\item if \emph{path} is a symlink, \texttt{stat()} returns information about the |
| 808 | +file the symlink refers to. \texttt{lstat()} function returns information about the link |
809 | 809 | itself. |
810 | 810 | \end{itemize} |
811 | 811 | \end{slide} |
|
865 | 865 | \texttt{ int \funnm{unlink}(const char *\emph{path});} |
866 | 866 | \begin{itemize} |
867 | 867 | \item deletes a name (i.e. a directory entry) and after deleting the last link to |
868 | | -the file and after closing the file by all processes, delete the file data. |
| 868 | +the file and after closing the file by all processes, deletes the file data. |
869 | 869 | \end{itemize} |
870 | 870 | \texttt{int \funnm{rename}(const char *\emph{old}, const char *\emph{new});} |
871 | 871 | \begin{itemize} |
872 | | -\item change the file name (i.e. one specific link) from \emph{old} to |
| 872 | +\item changes the file name (i.e. one specific link) from \emph{old} to |
873 | 873 | \emph{new}. Works within the same filesystem only. |
874 | 874 | \end{itemize} |
875 | 875 | \end{slide} |
|
882 | 882 | links between filesystems, symlinks are needed. A number of hardlinks to a |
883 | 883 | specific file is only limited by the size of the \texttt{st\_nlink} member of |
884 | 884 | \texttt{struct stat}, and the specification does not specify the size, it only |
885 | | -says its type \texttt{nlink\_t} is of an integer value. |
| 885 | +says its type \texttt{nlink\_t} is an integer value. |
886 | 886 | \item The parameter \emph{path2} must not exist. So, you cannot rename using |
887 | 887 | the \texttt{link} call. |
888 | 888 | \item \texttt{unlink} does not work on directories. |
889 | 889 | \item The shell command \texttt{mv} uses \texttt{rename} to move objects within |
890 | | -the same filesystems. To move files between filesystems, a file needs to be |
891 | | -copied first, then \texttt{unlink} it from the originating filesystem (the whole |
| 890 | +the same filesystem. To move files between filesystems, a file needs to be |
| 891 | +copied first, then \texttt{unlink}ed from the originating filesystem (the whole |
892 | 892 | operation is not atomic). |
893 | 893 | \item \texttt{rename} renames symlinks, not the files those symlinks point to. |
894 | 894 | \item There is also a more generic call \texttt{remove}, see page |
|
927 | 927 | \item Calling \texttt{unlink} on a hardlink will not release the file data if |
928 | 928 | other hardlinks exists. You can delete the symlink's target in which case you |
929 | 929 | end up with a \emph{broken link}. |
930 | | -\item \texttt{readlink} is useful in situation when you want to \texttt{unlink} |
| 930 | +\item \texttt{readlink} is useful in the situation where you want to \texttt{unlink} |
931 | 931 | the symlink's target. |
932 | 932 | \item \emph{\texttt{bufsize}} is typically set as 1 byte less than the buffer |
933 | 933 | size to accommodate the terminating \texttt{NULL} character. |
|
944 | 944 | \texttt{int \funnm{mkdir}(const char *\emph{path}, mode\_t \emph{mode});} |
945 | 945 | \begin{itemize} |
946 | 946 | \item attempts to create an empty directory \emph{path} with entries |
947 | | -'\texttt{.}' a '\texttt{..}' |
| 947 | +'\texttt{.}' and '\texttt{..}' |
948 | 948 | \end{itemize} |
949 | 949 | \texttt{int \funnm{rmdir}(const char *\emph{path});} |
950 | 950 | \begin{itemize} |
|
970 | 970 | \texttt{readdir} is allowed to return them in arbitrary order depending on the |
971 | 971 | filesystem implementation. \texttt{NULL} is returned on failure |
972 | 972 | and \texttt{errno} is set. \texttt{NULL} is also returned upon reaching the end |
973 | | -of a directory but in that case \texttt{errno} is not changed. |
| 973 | +of a directory but in that case, \texttt{errno} is not changed. |
974 | 974 | \item \texttt{readdir} is a stateful function. To read the directory from the |
975 | 975 | beginning again, \texttt{rewinddir} can be used. If you want to read the |
976 | 976 | directory from multiple threads, use the reentrant version, \texttt{readdir\_r}. |
|
1041 | 1041 | \texttt{int \funnm{chdir}(const char *\emph{path});}\\ |
1042 | 1042 | \texttt{int \funnm{fchdir}(int \emph{fildes});} |
1043 | 1043 | \begin{itemize} |
1044 | | -\item changes working directory for the process |
| 1044 | +\item changes the working directory for the process |
1045 | 1045 | \end{itemize} |
1046 | 1046 | \texttt{char *\funnm{getcwd}(char *\emph{buf}, size\_t \emph{size});} |
1047 | 1047 | \begin{itemize} |
|
1053 | 1053 | \begin{itemize} |
1054 | 1054 | \item The descriptor for \texttt{fchdir} is from \texttt{open} called on the |
1055 | 1055 | directory (i.e. not from \texttt{opendir}). |
1056 | | -\item There is also a function \texttt{chroot} which allows to change the root |
| 1056 | +\item There is also a function \texttt{chroot} which changes the root |
1057 | 1057 | directory of a calling process to a new one. It is often used in various server |
1058 | 1058 | implementations to limit access to the specific subtree. For example, for an |
1059 | 1059 | FTP server. You have to be careful though and make sure it is not possible to |
|
1103 | 1103 | different file to what it actually had no rights to manipulate with. If the |
1104 | 1104 | timing is right, the SUID process will operate on that other file. The correct |
1105 | 1105 | solution is not to use the \texttt{access} call but return to the real UID/GID |
1106 | | -and try the operation. For example, if we succeed to open the file under the |
| 1106 | +and try the operation. For example, if we succeed in opening the file under the |
1107 | 1107 | real UID/GID and continue working with the file descriptor, the file |
1108 | 1108 | manipulation mentioned above would not gain the attacker anything. |
1109 | 1109 | \end{itemize} |
|
1130 | 1130 | \begin{itemize} |
1131 | 1131 | \item changes file owner and group for \emph{path}. Value of |
1132 | 1132 | \texttt{-1} means do not change that ID. |
1133 | | -\item only root change change owners so that users could not work around quotas |
| 1133 | +\item only root can change owners so that users could not work around quotas |
1134 | 1134 | to disown their files |
1135 | 1135 | \item a regular user can change a group of files he/she owns, and must belong to |
1136 | 1136 | the target group |
|
1143 | 1143 | masks. |
1144 | 1144 | \item Only the owner of a file can change its mode. Mode like |
1145 | 1145 | \texttt{rw-rw-rw-} has nothing to do with that. |
1146 | | -\item In some implementations it was possible to pass the file ownership to |
| 1146 | +\item In some implementations, it was possible to pass the file ownership to |
1147 | 1147 | someone else. Today this is usually not allowed. Just think about how you |
1148 | 1148 | could work around a per-user filesystem quota with this. |
1149 | 1149 | \end{itemize} |
|
0 commit comments