Page 862 socketcallsocketcallSocket system calls SYPNOSIS int socketcall(int call, unsigned long *args); DESCRIPTION socketcall is a common kernel entry point for the socket system calls. call determines which socket function to invoke. args points to a block containing the actual arguments, which are passed through to the appropriate call. User programs should call the appropriate functions by their usual names. Only standard library implementors and kernel hackers need to know about socketcall. SEE ALSO accept(2), bind(2), connect(2), getpeername(2), getsockname(2), getsockopt(2), listen(2), recv(2), recvfrom(2), send(2), sendto(2), setsockopt(2), shutdown(2), socket(2), socketpair(2) Linux 1.2.4, 15 April 1995 socketpairsocketpairCreates a pair of connected sockets SYPNOSIS #include <sys/types.h> #include <sys/socket.h> int socketpair(int d, int type, int protocol, int sv[2]); DESCRIPTION The call creates an unnamed pair of connected sockets in the specified domain d, of the specified type, and using the optionally specified protocol. The descriptors used in referencing the new sockets are returned in sv[0] and sv[1]. The two sockets are indistinguishable. RETURN VALUE On success, 0 is returned. On error, _1 is returned, and errno is set appropriately. ERRORS
HISTORY The socketpair function call appeared in BSD 4.2. BUGS This call is currently implemented only for the UNIX domain. Page 863 SEE ALSO read(2), write(2), pipe(2) BSD Man Page, 24 July 1993 stat, fstat, lstatstat, fstat, lstatGet file status SYPNOSIS #include <sys/stat.h> #include <unistd.h> int stat(const char *file_name,struct stat *buf); int fstat(int filedes,struct stat *buf); int lstat(const char *file_name, struct stat *buf); 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. lstat is identical to stat, except that the link itself is stated, not the file that is obtained by tracing the links. fstat is identical to stat, except that the open file pointed to by filedes (as returned by open(2)) is stated in place of file_name. They all return a stat structure, which is declared as follows: struct stat { dev_t st_dev; /* device */ ino_t st_ino; /* inode */ umode_t st_mode; /*protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device type (if inode device) */ off_t st_size; /* total size, in bytes */ unsigned long st_blksize; /* blocksize for filesystem I/O */ unsigned long st_blocks; /* number of blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last change */ }; Note that st_blocks may not always be in terms of blocks of size st_blksize, and that st_blksize may instead provide a notion of the "preferred" block size for efficient filesystem I/O. Not all the Linux filesystems implement all the time fields. Traditionally, st_atime is changed by mknod(2), utime(2), read(2), write(2), and truncate(2). Traditionally, st_mtime is changed by mknod(2), utime(2), and write(2). st_mtime is not changed for changes in owner, group, hard link count, or mode. Traditionally, st_ctime is changed by writing or by setting inode information (that is, owner, group, link count, mode, and so on). Page 864 The following macros are defined to check the file type:
The following flags are defined for the st_mode field:
RETURN VALUE On success, 0 is returned. On error, _1 is returned, and errno is set appropriately. ERRORS
CONFORMS TO SVID (not lstat()), AT&T (not lstat()), POSIX (not lstat()), X/OPEN (not lstat()), BSD 4.3 SEE ALSO chmod(2), chown(2), readlink(2), utime(2) Linux 1.1.75, 1 January 1995 Page 865 statfs, fstatfsstatfs, fstatfsGet filesystem statistics SYPNOSIS #include <sys/vfs.h> int statfs(const char *path, struct statfs *buf); int fstatfs(int fd, struct statfs *buf); DESCRIPTION statfs returns information about a mounted filesystem. path is the pathname of any file within the mounted filesystem. buf is a pointer to a statfs structure defined as follows: struct statfs { long f_type; /* type of filesystem (see below) */ long f_bsize; /* optimal transfer block size */ long f_blocks; /* total data blocks in filesystem */ long f_bfree; /* free blocks in fs */ long f_bavail; /* free blocks avail to non-superuser */ long f_files; /* total file nodes in filesystem */ long f_ffree; /* free file nodes in fs */ fsid_t f_fsid; /* filesystem id */ long f_namelen; /* maximum length of filenames */ long f_spare[6]; /* spare for later */ }; Filesystem types: linux/ext2_fs.h: EXT2_OLD_SUPER_MAGIC 0xEF51 linux/ext2_fs.h: EXT2_SUPER_MAGIC 0xEF53 linux/ext_fs.h: EXT_SUPER_MAGIC 0x137D linux/iso_fs.h: ISOFS_SUPER_MAGIC 0x9660 linux/minix_fs.h: MINIX_SUPER_MAGIC 0x137F /* orig. minix */ linux/minix_fs.h: MINIX_SUPER_MAGIC2 0x138F /* 30 char minix */ linux/minix_fs.h: NEW_MINIX_SUPER_MAGIC 0x2468 /* minix V2 */ linux/msdos_fs.h: MSDOS_SUPER_MAGIC 0x4d44 linux/nfs_fs.h: NFS_SUPER_MAGIC 0x6969 linux/proc_fs.h: PROC_SUPER_MAGIC 0x9fa0 linux/xia_fs.h: XIAFS_SUPER_MAGIC 0x012FD16D Fields that are undefined for a particular filesystem are set to _1. fstatfs returns the same information about an open file referenced by descriptor fd. RETURN VALUE On success, 0 is returned. On error, _1 is returned, and errno is set appropriately. ERRORS For statfs:
|