* file systems demo Use 'man' command on unix systems to get help pages on commands and system calls Man pages broken into sections: 1: basic unix commands 2: system calls (OS functions) 3: library calls 8: system administrator privileged commands (need sudo access) every dir has '.': current working dir and '..' (parent dir) list files using 'ls' stat(2): syscall to retrieve m-d of any object stat(1): unix cmd to issue stat(2) and show contents file permissions broken into r: read w: write x: execute rwx for 3 groups: owner, any group members, and all others e.g., -rw-r--r--: owner (left 3 bits): can read+write group member can read only others can read only see man chmod(1)/chmod(2) $ man 1 chmod $ man 2 chmod Unix timestamps: 1. access: last time file was read (atime) 2. modify: last time file's contents was modified (mtime) 3. change: last time the file's inode changed (ctime) e.g., if you change permissions, owner/group, size ctime is NOT "create time" 4. macos added "birth time" or true file creation time it's immutable, cannot be changed How to change: names: rename syscall or "mv" command owner: chown group: chgrp permissions: chmod timestamps: utimes * file contents can be displayed using commands such as "cat", "more", "less", etc. $ cat foo adding content to file $ echo hello world > foo print "hello world" on display, but redirect it to file foo $ od -a foo shows file content incl special chars Now stat shows that file size is 12 (bytes) and 8 (blocks). Block size is 4096 (this is f/s block size, not underlying disk block size). - storage dev can only alloc in sector/block chunks (e.g., 512B) - f/s asks disk to get at least one block - f/s then fill in that block w/ the file's contents ("hello world\n") - f/s records how many BYTES were used out of the allocated blocks Note: on this system, the f/s block size is 4096, but the initial allocation of blocks was 8. Why? B/c the underlying storage sector size is 4096/8=512B (i.e., "older" block sizes). The inode for 'foo' will now have links to 8 sectors on the disk, with their numbers. I can now fill the file up to 4096B, after that, the f/s will have to alloc another 4K chunk. append to a file: $ echo hi there >> foo Permissions: - only owner can change permissions or gid of a file - group members + others w/ 'w' permission can modify file content only - who can change a file ownership (chown)? root POSIX standard (~40 year old) codifies Unix syscall semantics - many subsets of POSIX. This f/s decided that it's alloc size is 4KB, decided at format time. Format commands on some OSs allow you to choose the native f/s alloc size (the the min size allocated to a file even if you write just 1B). Use a smaller f/s block size if your workload is expected to be a lot of smaller files; use larger f/s block size if you expect to store a few much larger files (e.g., media, databases, VM images). You can stat a dir too $ stat . $ stat .. * piazza Signup link: https://piazza.com/stonybrook/spring2025/cse590t02 Auditing the class? Please reg w/ above link, else send me an email and I'll reg you. IMPORTANT: for future announcements.