Page 869 SEE ALSO link(2), unlink(2), rename(2), open(2), lstat(2), ln(1), link(8) Linux, 24 July 1993 syncsyncCommits buffer cache to disk SYPNOSIS #include <unistd.h> int sync(void); DESCRIPTION sync first commits inodes to buffers, and then buffers to disk. RETURN VALUE sync always returns 0. CONFORMS TO SVID, AT&T, X/OPEN, BSD 4.3 BUGS According to the standard specification (for example, SVID), sync() schedules the writes, but it might return before the actual writing is done. However, since version 1.3.20, Linux does actually wait. (This still does not guarantee data integrity; modern disks have large caches.) SEE ALSO bdflush(2), fsync(2), fdatasync(2), update(8), sync(8) Linux 1.3.88, 15 April 1995 sysctlsysctlReads/writes system parameters SYPNOSIS #include <unistd.h> #include <linux/unistd.h> #include <linux/sysctl.h> _syscall1(int_sysctl, struct __sysctl_args *args); int sysctl(struct __sysctl_args *args); DESCRIPTION The sysctl call reads and/or writes kernel parametersfor example, the hostname or the maximum number of open files. The argument has the form struct __sysctl__args { int *name; /* integer vector describing variable */ int nlen; /* length of this vector */ void *oldval; /* 0 or address where to store old value */ size_t *oldlenp; /* available room for old value, Page 870 overwritten by actual size of old value */ void *newval; /* 0 or address of new value */ size_t newlen; /* size of new value */ }; This call does a search in a tree structure, possibly resembling a directory tree under /proc/sys, and, if the requested item is found, calls some appropriate routine to read or modify the value. Example #include <linux/unistd.h> #include <linux/types.h> #include <linux/sysctl.h> _syscall1(int, _sysctl, struct __sysctl args *, args); int sysctl(int *name, int nlen, void *oldval, size_t *oldlenp, void *newval, size_t newlen) { struct __sysctl__args args={name,nlen,oldval,oldlenp,newval,newlen}; return _sysctl(&args); } #define SIZE(x) sizeof(x)/sizeof(x[0]) #define OSNAMESZ 100 char osname[OSNAMESZ]; int osnamelth; int name[] = { CTL_KERN, KERN_OSTYPE }; main(){ osnamelth = SIZE(osname); if (sysctl(name, SIZE(name), osname, &osnamelth, 0, 0)) perror("sysctl"); else printf("This machine is running %*s\n", osnamelth, osname); return 0; } RETURN VALUES Upon successful completion, sysctl returns 0. Otherwise, a value of _1 is returned, and errno is set to indicate the error. ERRORS
CONFORMS TO This call is Linux specific. HISTORY A sysctl call has been present in Linux since version 1.3.57. It originated in BSD-4.4. Only Linux has the /proc/sys mirror, and the object-naming schemes differ between Linux and BSD 4.4, but the declaration of the sysctl(2) function is the same in both. Page 871 BUGS Not all available objects are properly documented. It is not yet possible to change operating system by writing to /proc/sys/kernel/ostype. SEE ALSO proc(5) Linux 1.3.85, 11 April 1996 sysfssysfsGets filesystem type information SYPNOSIS int sysfs(int option, const char * fsname); int sysfs(int option, unsigned int fs_index, char * buf); int sysfs(int option); DESCRIPTION sysfs returns information about the filesystem types currently present in the kernel. The specific form of the sysfs call and the information returned depend on the option in effect. You can
The numbering of the filesystem type indexes begins with 0. RETURN VALUE On success, sysfs returns the filesystem index for the first option, 0 for the second option, and the number of currently configured filesystems for the third option. On error, _1 is returned, and errno is set appropriately. ERRORS
CONFORMS TO System V Linux 1.3.16, 9 August 1995 sysinfosysinfoReturns information on overall system statistics SYPNOSIS As of Linux 0.99.10 and image release 4.4, #include <linux/kernel.h> #include <linux/sys.h> int sysinfo(struct sysinfo *info); Page 872 DESCRIPTION sysinfo returns information in the following structure: struct sysinfo { long uptime; /* Seconds since boot */ unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ unsigned long totalram; /* Total usable main memory size */ unsigned long freeram; /* Available memory size */ unsigned long sharedram; /* Amount of shared memory */ unsigned long bufferram; /* Memory used by buffers */ unsigned long totalswap; /* Total swap space size */ unsigned long freeswap; /* swap space still available */ unsigned short procs; /* Number of current processes */ char _f[22]; /* Pads structure to 64 bytes */ }; sysinfo provides a simple way of getting overall system statistics. This is more portable than reading /dev/kmem. RETURN VALUE On success, 0 is returned. On error, _1 is returned, and errno is set appropriately. ERRORS
CONFORMS TO This function is Linux specific. BUGS The Linux DLL 4.4.1 libraries do not contain a proper prototype for this function. Linux 0.99.10, 24 July 1993 syslogsyslogReads and/or clears kernel message ring buffer; sets console_loglevel SYPNOSIS #include <unistd.h> #include <linux/unistd.h> _syscall3(int syslog, int type, char *bufp, int len); int syslog(int type, char *bufp, int len); DESCRIPTION This is probably not the function you are interested in. Look at syslog(3) for the C library interface. This page only documents the bare kernel system call interface. The type argument determines the action taken by syslog. From kernel/printk.c:/* Valid commands to syslog are 0Close the log. Currently a NOP. 1Open the log. Currently a NOP. 2Read from the log. |