/* * Sample program for mount and umount system call - No.21, No.22 * * mount, umount - mount and umount filesystems * * Synopsis * #include * * int mount(const char *source, const char *target, * const char *filesystemtype, unsigned long mountflags, * const void *data); * int umount(const char *target); * * Macros - * #define MS_RDONLY 1 * mount read-only * * #define MS_NOSUID 2 * ignore suid and sgid bits * * #define MS_NODEV 4 * no access to device special files * * #define MS_NOEXEC 8 * no program execution * * #define MS_SYNCHRONOUS 16 * writes are synced at once * * #define MS_REMOUNT 32 * alter flags of a mounted fs * * #define MS_MANDLOCK 64 * allow mandatory locks * * #define MS_NOATIME 1024 * do not update access times * * #define MS_NODIRATIME 2048 * do not update dir access times * * #define MS_BIND 4096 * bind subtree elsewhere * * #define MS_MOVE 8192 * atomically move subtree * * * Supported filesystems * adfs, affs, autofs, coda, coherent, cramfs, devpts, efs, ext, * ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, * ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, * ufs, umsdos, vfat, xenix, xfs, xiafs */ #include #include main() { mount("/dev/cdrom", "/mnt/cdrom", "iso9660", MS_RDONLY, NULL); system("ls /mnt/cdrom"); umount("/mnt/cdrom"); exit(0); }