stat(2) stat(2) strcpy(3) strcpy(3) stat, lstat − get file status

stat(2) stat(2) strcpy(3) strcpy(3) stat, lstat − get file status
stat(2)
stat(2)
NAME
strcpy(3)
strcpy(3)
NAME
stat, lstat − get file status
strcpy, strncpy − copy a string
SYNOPSIS
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
char *strcpy(char *dest, const char *src);
int stat(const char * file_name, struct stat *buf );
int lstat(const char * file_name, struct stat *buf );
char *strncpy(char *dest, const char *src, size_t n);
DESCRIPTION
The strcpy() function copies the string pointed to by src (including the terminating ‘\0’ character) to the
array pointed to by dest. The strings may not overlap, and the destination string dest must be large enough
to receive the copy.
DESCRIPTION
These functions return information about the specified file. You do not need any access rights to the file to
get this information but you need search rights to all directories named in the path leading to the file.
stat stats the file pointed to by file_name and fills in buf .
The strncpy() function is similar, except that not more than n bytes of src are copied. Thus, if there is no
null byte among the first n bytes of src, the result will not be null-terminated.
lstat is identical to stat, except in the case of a symbolic link, where the link itself is stat-ed, not the file that
it refers to.
In the case where the length of src is less than that of n, the remainder of dest will be padded with null
bytes.
They all return a stat structure, which contains the following fields:
struct stat {
dev_t
ino_t
mode_t
nlink_t
uid_t
gid_t
dev_t
off_t
blksize_t
blkcnt_t
time_t
time_t
time_t
};
RETURN VALUE
The strcpy() and strncpy() functions return a pointer to the destination string dest.
st_dev;
/* device */
st_ino; /* inode */
st_mode; /* protection */
st_nlink; /* number of hard links */
st_uid; /* user ID of owner */
st_gid; /* group ID of owner */
st_rdev; /* device type (if inode device) */
st_size; /* total size, in bytes */
st_blksize; /* blocksize for filesystem I/O */
st_blocks; /* number of blocks allocated */
st_atime; /* time of last access */
st_mtime; /* time of last modification */
st_ctime; /* time of last status change */
BUGS
If the destination string of a strcpy() is not large enough (that is, if the programmer was stupid/lazy, and
failed to check the size before copying) then anything might happen. Overflowing fixed length strings is a
favourite cracker technique.
CONFORMING TO
SVr4, 4.3BSD, C89, C99.
SEE ALSO
bcopy(3), memccpy(3), memcpy(3), memmove(3), wcscpy(3), wcsncpy(3)
The value st_size gives the size of the file (if it is a regular file or a symlink) in bytes. The size of a symlink
is the length of the pathname it contains, without trailing NUL.
Not all of the Linux filesystems implement all of the time fields. Some file system types allow mounting in
such a way that file accesses do not cause an update of the st_atime field. (See ‘noatime’ in mount(8).)
The field st_atime is changed by file accesses, e.g. by execve(2), mknod(2), pipe(2), utime(2) and read(2)
(of more than zero bytes). Other routines, like mmap(2), may or may not update st_atime.
The field st_mtime is changed by file modifications, e.g. by mknod(2), truncate(2), utime(2) and write(2)
(of more than zero bytes). Moreover, st_mtime of a directory is changed by the creation or deletion of files
in that directory. The st_mtime field is not changed for changes in owner, group, hard link count, or mode.
The field st_ctime is changed by writing or by setting inode information (i.e., owner, group, link count,
mode, etc.).
RETURN VALUE
On success, zero is returned. On error, −1 is returned, and errno is set appropriately.
SOSI-Klausur Manual-Auszug
2007-06-13
1
SOSI-Klausur Manual-Auszug
2007-06-13
1
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement