/* * Sample program for ustat system call - No.62 * * ustat - get file system statistics * * Synopsis * #include * #include * #include * * int ustat(dev_t dev, struct ustat *ubuf); * * Description * ustat returns information about a mounted file system. * dev is a device number identifying a device containing a * mounted file system. ubuf is a pointer to a ustat structure * that contains the following members: * * daddr_t f_tfree; * Total free blocks * * ino_t f_tinode; * Number of free inodes * * char f_fname[6]; * Filsys name * * char f_fpack[6]; * Filsys pack name * * * The last two fields, f_fname anf f_fpack, are not implemented * and will always be filled with null characters. * * Retrun value * On success, zero is returned and the ustat structure * pointed to bye ubuf will be filled in. On error, -1 is * is returned, and errno is set appropriately. * * Notes * ustat has only been provided for compatibility. All new * programs should use statfs(2) instead. * * Types * in * struct dev_t * { * unsigned long __val[2]; * } * * in * struct ustat * { * daddr_t f_tfree; * ino_t f_tinode; * char f_fname[6]; * char f_fpack[6]; * }; * * Macros * in * major(dev) * minor(dev) * makedev(major, minor) */ #include #include main() { struct ustat fs_stat; dev_t dev_num; int m, n; printf("major number = "); scanf("%d", &m); printf("minor number = "); scanf("%d", &n); dev_num = makedev(m, n); ustat(dev_num, &fs_stat); printf("f_tfree = %d\n", fs_stat.f_tfree); printf("f_tinode = %lu\n", fs_stat.f_tinode); printf("f_fname = %s\n", fs_stat.f_fname); printf("f_fpack = %s\n", fs_stat.f_fpack); exit(0); }