Files and Directories Filesystems from a user s perspective

Size: px
Start display at page:

Download "Files and Directories Filesystems from a user s perspective"

Transcription

1 Files and Directories Filesystems from a user s perspective Unix Filesystems Seminar Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz December, Alexander Holupirek (U KN) Files & Directories December, / 57

2 Introduction Introduction Last session: Additional features of the filesystem. Properties of a file. The stat functions. Members of the stat structure. (ZFS interview) Today: The structure of a Unix filesystem. Remaining members of the stat structure. Filesystem structure (i-nodes etc.). Next: The Standard I/O library Streams and FILE Objects Buffering Formatted I/O Alternatives to Standard I/O Alexander Holupirek (U KN) Files & Directories December, / 57

3 Members of the stat struct The structure mode_t st_mode ; /* inode s mode */ uid_t st_uid ; /* user ID of owner */ gid_t st_gid ; /* group ID of owner */ off_t st_size ; /* file size, in bytes */ int64_t st_blocks ; /* blocks allocated for file */ u_int32_t st_blksize ;/* optimal file sys I/ O ops blocksize */ dev_t st_dev ; /* device inode resides on */ ino_t st_ino ; /* inode s number */ nlink_t st_nlink ; /* number of hard links to the file */ dev_t st_rdev ; /* device type, for special file inode */ struct timespec st_atimespec ; /* time of last access */ struct timespec st_mtimespec ; /* time of last data modification */ struct timespec st_ctimespec ; /* time of last file status change */ Alexander Holupirek (U KN) Files & Directories December, / 57

4 st size, st blocks, st blksize The size-related fields struct stat { off_t st_size ; /* file size, in bytes */ int64_t st_blocks ; /* blocks allocated for file */ u_int32_t st_blksize ;/* optimal file sys I/ O ops blocksize */ }; st size Regular file. File size of 0 is allowed (EOF on read). Symbolic link. Actual number of bytes of the targetstring w/o terminating null byte (explicit length is given). st blocks The actual number of blocks allocated for the file in 512-byte units (non-portable!). As short symbolic links are stored in the i-node, this number may be zero. st blksize The optimal I/O block size for the file (standard I/O library). Alexander Holupirek (U KN) Files & Directories December, / 57

5 Write a single byte file. The stat structure The size-related fields Snippets from write single byte file.c: const char * fname = "./ single_byte_file "; const char * abc = "a"; if (( fd = open ( fname, O_CREAT O_TRUNC O_RDWR, 0600 )) == -1) err ( errno, " can not creat %s [%d]", fname, errno ); if (( wb = write (fd, abc, strlen ( abc ))) == -1) err ( errno, " can not write to fd %d ", fd ); Examine written file: $ ls -l single_byte_file -rw holu holu 1 Dec 11 10:22 single_byte_file $ du single_byte_file 2 single_byte_file Alexander Holupirek (U KN) Files & Directories December, / 57

6 getbsize(3) and du(1) getbsize(3) and du(1) getbsize(3) - get user block size The getbsize(3) function determines the user s preferred block size. # include < stdlib.h> char * getbsize ( int * headerlenp, long * blocksizep ); du(1) - display disk usage statistics The du(1) utility displays the file system block usage for each file argument and for each directory in the file hierarchy rooted in each directory argument. Alexander Holupirek (U KN) Files & Directories December, / 57

7 statfs(2) - get file system statistics # include <sys / param.h> # include <sys / mount.h> int statfs ( const char * path, struct statfs * buf ); struct statfs { u_int32_t f_flags ; /* copy of mount flags */ int32_t f_bsize ; /* fundamental file system block size */ u_int32_t f_iosize ; /* optimal transfer block size */ u_int32_t f_blocks ; /* total data blocks in file system */ u_int32_t f_bfree ; /* free blocks in fs */ int32_t f_bavail ; /* free blocks avail to non - superuser */ u_int32_t f_files ; /* total file nodes in file system */ u_int32_t f_ffree ; /* free file nodes in fs */ fsid_t f_fsid ; /* file system id */ uid_t f_owner ; /* user that mounted the file system */ u_int32_t f_syncwrites ; /* count of sync writes since mount */ u_int32_t f_asyncwrites ; /* count of async writes since mount */ u_int32_t f_ctime ; /* last mount [- u] time */ u_int32_t f_spare [3]; /* spare for later */ char f_fstypename [ MFSNAMELEN ]; /* fs type name */ char f_mntonname [ MNAMELEN ]; /* dir on which mounted */ char f_mntfromname [ MNAMELEN ]; /* mounted file system */ union mount_info mount_info ; /* per - fs mount options */ }; Alexander Holupirek (U KN) Files & Directories December, / 57

8 Write a single byte file (cont.) statfs(2) - get file system statistics Get some background information: $./ write_single_byte_file getbsize : 512 /* block size preferred by user */ st_size : 1 st_blocks : 4 /* 4 x 512 = 2048 */ st_blksize : f_bsize : 2048 /* fundamental filesystem block size */ f_iosize : Compare it: $ ls -l single_byte_file -rw holu holu 1 Dec 11 09:45 single_byte_file $ du single_byte_file 2 single_byte_file /* 2 * 1024 = 2048 */ File occupies one filesystem data block (2K) to store the single byte. Alexander Holupirek (U KN) Files & Directories December, / 57

9 Write a 2K file The stat structure Writing files in different sizes $./ write_2k_file getbsize : 512 st_size : 2048 st_blocks : 4 st_blksize : f_bsize : 2048 f_iosize : $ ls -l 2 K_file -rw holu holu 2048 Dec 11 11:06 2 K_file $ du 2 K_file 2 2 K_file $ ls -l single_byte_file -rw holu holu 1 Dec 11 11:05 single_byte_file $ du single_byte_file 2 single_byte_file No change in disk usage. Alexander Holupirek (U KN) Files & Directories December, / 57

10 Writing files with holes Holes in a file - write(2) and lseek(2) write(2) - reposition read/write file offset # include <sys / types.h> # include < unistd.h> ssize_t write ( int d, const void * buf, size_t nbytes ); lseek(2) - reposition read/write file offset # include < unistd.h> off_t lseek ( int fildes, off_t offset, int whence ); If whence is SEEK_SET, offset is set to offset bytes. If whence is SEEK_CUR, offset is current location plus offset bytes. If whence is SEEK_END, offset is size of file plus offset bytes. Alexander Holupirek (U KN) Files & Directories December, / 57

11 Writing files with holes /* hole.c */ const char * fname = "./ file_with_hole "; const char * abc = " abcdefghij "; const char * ABC = " ABCDEFGHIJ "; if (( fd = open ( fname, O_CREAT O_TRUNC O_RDWR, 0600 )) == -1) err ( errno, " can not creat %s [%d]", fname, errno ); if (( wb = write (fd, abc, strlen ( abc ))) == -1) err ( errno, " can not write to fd %d ", fd ); else printf (" wrote %ld bytes.\n", wb ); if ( lseek (fd, 20, SEEK_CUR ) == -1) err ( errno, " can not seek [%d].", errno ); else printf (" seek 20 bytes.\n" ); } if (( wb = write (fd, ABC, strlen ( ABC ))) == -1) err ( errno, " can not write to fd %d ", fd ); else printf (" wrote %ld bytes.\n", wb ); Alexander Holupirek (U KN) Files & Directories December, / 57

12 Writing files with holes Holes in a file - write(2) and lseek(2) $./ hole wrote 10 bytes. lseek 20 bytes. wrote 10 bytes. getbsize : 512 st_size : 40 st_blocks : 4 st_blksize : f_bsize : 2048 f_iosize : $ ls -l file_with_hole check its size -rw holu holu 40 Nov 25 17:24 file_with_hole $ od -c file_with_hole examine actual content 000 a b c d e f g h i j \0 \0 \0 \0 \0 \0 020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 A B 040 C D E F G H I J Holes are created by seeking past the current end of file. Alexander Holupirek (U KN) Files & Directories December, / 57

13 64K files (with holes) The stat structure Writing files with holes # define NBLK 4 # define BSIZ /* snippet to write a 64K file */ for (i = 0; i < NBLK ; i ++) { for (j = 0; j < BSIZ ; j ++) { if (( wb = write (fd, abc, strlen ( abc ))) == -1) err ( errno, " can not write to fd %d ", fd ); } } # define NBLK 2 /* snippet to write a 64K file with holes */ for (i = 0; i < NBLK ; i ++) { if ( lseek ( fd, BSIZ, SEEK_CUR ) == -1) err ( errno, " can not seek [%d].", errno ); for (j = 0; j < BSIZ ; j ++) { if (( wb = write (fd, abc, strlen ( abc ))) == -1) err ( errno, " can not write to fd %d ", fd ); } } Alexander Holupirek (U KN) Files & Directories December, / 57

14 Write 64K files (with holes) Writing files with holes $./ write_64k_file st_size : st_blocks : 128 /* 128 x 512 = */ $./ write_64k_file_with_holes st_size : st_blocks : 64 /* 64 x 512 = */ $ od -c 64 K_file a a a a a a a a a a a a a a a a * $ od -c 64 K_file_with_holes \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * a a a a a a a a a a a a a a a a * \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * a a a a a a a a a a a a a a a a * Alexander Holupirek (U KN) Files & Directories December, / 57

15 File with holes (cont.) The stat structure Writing files with holes $ ls -l 64 K_file * -rw holu holu Dec 11 12:41 64 K_file -rw holu holu Dec 11 12:41 64 K_file_with_holes $ du 64 K_file * K_file /* 64 x 1024 = */ K_file_with_holes /* 32 x 1024 = */ $ cat 64 K_file_with_holes > 64 K_file_with_holes. copy $ od -c 64 K_file_with_holes. copy \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * a a a a a a a a a a a a a a a a * \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 * a a a a a a a a a a a a a a a a * Alexander Holupirek (U KN) Files & Directories December, / 57

16 File with holes (cont.) The stat structure Writing files with holes $ ls -l 64 K_file * -rw holu holu Dec 11 12:41 64 K_file -rw holu holu Dec 11 12:41 64 K_file_with_holes -rw -r--r-- 1 holu holu Dec 11 12:42 64 K_file_with_holes. copy $ du 64 K_file * K_file K_file_with_holes K_file_with_holes. copy Alexander Holupirek (U KN) Files & Directories December, / 57

17 Filesystem structure Device number, i-node and hard links struct stat { dev_t st_dev ; /* device inode resides on */ ino_t st_ino ; /* inode s number */ nlink_t st_nlink ; /* number of hard links to the file */ }; To understand these members, we need to know the difference between an i-node and a directory entry that refers to an i-node. This will be of importance when we talk about the concept of links to a file. Alexander Holupirek (U KN) Files & Directories December, / 57

18 Filesystem structure Disk drive, partitions, and a filesystem Abbildung: We can think of a disk drive being divided into one or more partitions. Each partition can contain a filesystem. i-nodes are fixed-length entries that contain most of the information about a file. Alexander Holupirek (U KN) Files & Directories December, / 57

19 A closer look at the filesystem Filesystem structure Abbildung: A filesystem in more detail (boot blocks and super block ignored). Two directory entries point to the same i-node. Alexander Holupirek (U KN) Files & Directories December, / 57

20 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. Alexander Holupirek (U KN) Files & Directories December, / 57

21 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. The link count contains the number of directory entries that point to the i-node. Alexander Holupirek (U KN) Files & Directories December, / 57

22 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. The link count contains the number of directory entries that point to the i-node. Only when the link count goes to zero can the file be deleted (i.e., can the associated data blocks be released). Alexander Holupirek (U KN) Files & Directories December, / 57

23 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. The link count contains the number of directory entries that point to the i-node. Only when the link count goes to zero can the file be deleted (i.e., can the associated data blocks be released). This is why unlinking a file does not always mean deleting the blocks associated with the file. Alexander Holupirek (U KN) Files & Directories December, / 57

24 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. The link count contains the number of directory entries that point to the i-node. Only when the link count goes to zero can the file be deleted (i.e., can the associated data blocks be released). This is why unlinking a file does not always mean deleting the blocks associated with the file. This is why the function that removes a directory entry is called unlink(2) and not delete. Alexander Holupirek (U KN) Files & Directories December, / 57

25 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. The link count contains the number of directory entries that point to the i-node. Only when the link count goes to zero can the file be deleted (i.e., can the associated data blocks be released). This is why unlinking a file does not always mean deleting the blocks associated with the file. This is why the function that removes a directory entry is called unlink(2) and not delete. These type of links are called hard links. Alexander Holupirek (U KN) Files & Directories December, / 57

26 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. The link count contains the number of directory entries that point to the i-node. Only when the link count goes to zero can the file be deleted (i.e., can the associated data blocks be released). This is why unlinking a file does not always mean deleting the blocks associated with the file. This is why the function that removes a directory entry is called unlink(2) and not delete. These type of links are called hard links. In the stat structure the link count is called st nlink and has type nlink t with limit LINK MAX. Alexander Holupirek (U KN) Files & Directories December, / 57

27 Filesystem structure link count, remove and unlink, hard link Every i-node has a link count. The link count contains the number of directory entries that point to the i-node. Only when the link count goes to zero can the file be deleted (i.e., can the associated data blocks be released). This is why unlinking a file does not always mean deleting the blocks associated with the file. This is why the function that removes a directory entry is called unlink(2) and not delete. These type of links are called hard links. In the stat structure the link count is called st nlink and has type nlink t with limit LINK MAX. (There is another link type, called symbolic link. Later.) Alexander Holupirek (U KN) Files & Directories December, / 57

28 Filesystem structure inode(5) - format of file system volume The i-node contains all information about a file the file type the file s access permission bits the size of the file pointers to the data blocks for the file Most stat entries are obtained from the i-node Which not? Alexander Holupirek (U KN) Files & Directories December, / 57

29 Filesystem structure inode(5) - format of file system volume The i-node contains all information about a file the file type the file s access permission bits the size of the file pointers to the data blocks for the file Most stat entries are obtained from the i-node Which not? file name and i-node number ino t are stored in the directory entry. Alexander Holupirek (U KN) Files & Directories December, / 57

30 Filesystem structure i-nodes, directory entries, and hard links i-node is filesystem bound It is assumed that the i-node number in the directory entry points to an i-node in the same filesystem. We cannot have a directory entry point to an i-node in a different filesystem. This is why the ln(1) command (make a new directory entry that points to an existing file) cannot cross filesystems. Alexander Holupirek (U KN) Files & Directories December, / 57

31 link(2) - make a hard file link Function that operate on links # include < unistd.h> int link ( const char * name1, const char * name2 ); The link(2) function atomically creates the specified directory entry (hard link) name2 with the attributes of the underlying object pointed at by name1. If the link is successful: the link count of the underlying object is incremented; name1 and name2 share equal access and rights to the underlying object. If name1 is removed, the file name2 is not deleted and the link count of the underlying object is decremented. name1 must exist for the hard link to succeed and both name1 and name2 must be in the same file system. As mandated by POSIX.1 name1 may not be a directory. Alexander Holupirek (U KN) Files & Directories December, / 57

32 unlink(2) - remove directory entry Function that operate on links # include < unistd.h> int unlink ( const char * path ); The unlink(2) function removes the link named by path from its directory. The link count of the file which was referenced by the link is decremented. If that decrement reduces the link count of the file to zero, and no process has the file open, then all resources associated with the file are reclaimed. If one or more processes have the file open when the last link is removed, the link is removed, but the removal of the file is delayed until all references to it have been closed. Alexander Holupirek (U KN) Files & Directories December, / 57

33 Function that operate on links remove(3) - remove a file or directory # include <stdio.h> int remove ( const char * path ); The remove(3) function removes the file or directory specified by path. If path specifies a directory, remove(path) is the equivalent of rmdir(path). Otherwise, it is the equivalent of unlink(path). Alexander Holupirek (U KN) Files & Directories December, / 57

34 Function that operate on links rename(2) - change the name of a file # include <stdio.h> int rename ( const char * from, const char * to ); rename(2) causes the link named from to be renamed as to. If to exists, it is first removed. Both from and to must be of the same type (that is, both directories or both non-directories), and must reside on the same file system. rename(2) guarantees that if to already exists, an instance of to will always exist, even if the system should crash in the middle of the operation. If the final component of from is a symbolic link, the symbolic link is renamed, not the file or directory to which it points. Alexander Holupirek (U KN) Files & Directories December, / 57

35 Notes on rename(2) The stat structure Function that operate on links When renaming a file without changing filesystems... the actual content of the file need not be moved. a new directory entry needs to point to the existing i-node the old directory entry has to be removed Example: rename( /usr/lib/foo, /usr/foo ) Assumption: /usr/lib and /usr are on the same filesystem Consequence: the contents of foo need not be moved This is how mv(1) usually operates Alexander Holupirek (U KN) Files & Directories December, / 57

36 Link count for directories Making a new directory in the working directory (mkdir testdir Abbildung: Filesystem state after the creation of testdir Alexander Holupirek (U KN) Files & Directories December, / 57

37 Link count for directories i-node 2549 has a type field of directory Alexander Holupirek (U KN) Files & Directories December, / 57

38 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Alexander Holupirek (U KN) Files & Directories December, / 57

39 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Any leaf directory always has a link count of 2 Alexander Holupirek (U KN) Files & Directories December, / 57

40 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Any leaf directory always has a link count of 2 One from the directory entry that names the directory (testdir) Alexander Holupirek (U KN) Files & Directories December, / 57

41 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Any leaf directory always has a link count of 2 One from the directory entry that names the directory (testdir) One from the dot entry in that directory. Alexander Holupirek (U KN) Files & Directories December, / 57

42 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Any leaf directory always has a link count of 2 One from the directory entry that names the directory (testdir) One from the dot entry in that directory. i-node 1267 has a type field of directory Alexander Holupirek (U KN) Files & Directories December, / 57

43 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Any leaf directory always has a link count of 2 One from the directory entry that names the directory (testdir) One from the dot entry in that directory. i-node 1267 has a type field of directory i-node 1267 has a link count greater than or equal to 3 Alexander Holupirek (U KN) Files & Directories December, / 57

44 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Any leaf directory always has a link count of 2 One from the directory entry that names the directory (testdir) One from the dot entry in that directory. i-node 1267 has a type field of directory i-node 1267 has a link count greater than or equal to 3 Why? Alexander Holupirek (U KN) Files & Directories December, / 57

45 Link count for directories i-node 2549 has a type field of directory i-node 2549 has a link count equal to 2 Any leaf directory always has a link count of 2 One from the directory entry that names the directory (testdir) One from the dot entry in that directory. i-node 1267 has a type field of directory i-node 1267 has a link count greater than or equal to 3 Why? The directory entry that names it, dot, and dot dot. Alexander Holupirek (U KN) Files & Directories December, / 57

46 Symbolic link The stat structure Symbolic link $ ls -l foobar lrwxr - xr - x 1 holu holu 3 Dec 11 09:08 foobar -> foo $ du foobar 0 foobar The actual content of the file (the data blocks) contains the name of the file that the symbolic link points to In the example above the filename in the directory entry is the six-character string foobar The three bytes of data in the file are foo The file type in the i-node is S IFLINK to denote the symbolic link Alexander Holupirek (U KN) Files & Directories December, / 57

47 Symbolic link The stat structure Symbolic link $ ls -l foobar lrwxr - xr - x 1 holu holu 3 Dec 11 09:08 foobar -> foo $ du foobar 0 foobar The actual content of the file (the data blocks) contains the name of the file that the symbolic link points to In the example above the filename in the directory entry is the six-character string foobar The three bytes of data in the file are foo The file type in the i-node is S IFLINK to denote the symbolic link What about the du result? Alexander Holupirek (U KN) Files & Directories December, / 57

48 Symbolic link The stat structure Symbolic link $ ls -l foobar lrwxr - xr - x 1 holu holu 3 Dec 11 09:08 foobar -> foo $ du foobar 0 foobar The actual content of the file (the data blocks) contains the name of the file that the symbolic link points to In the example above the filename in the directory entry is the six-character string foobar The three bytes of data in the file are foo The file type in the i-node is S IFLINK to denote the symbolic link What about the du result? Short symbolic links are stored inlined in the i-node $ ls -l a lrwxr - xr - x 1 holu holu 124 Dec 11 17:22 a -> bbb... $ du a 2 a Alexander Holupirek (U KN) Files & Directories December, / 57

49 Device numbers The stat structure Special Device Files dev_t st_dev ; /* device inode resides on */ dev_t st_rdev ; /* device type, for special file inode */ Every filesystem is known by its major and minor device number This device number is encoded in the primitive data type dev t Why? A disk drive often contains several filesystems The st dev value for every filename on a system is the device number of the filesystem containing that filename and its corresponding i-node Only character and block special files have an st rdev value This value contains the device number for the actual device Alexander Holupirek (U KN) Files & Directories December, / 57

50 The three time fields The stat structure File Times struct timespec st_atime ; /* time of last access */ struct timespec st_mtime ; /* time of last data modification */ struct timespec st_ctime ; /* last - change time of i- node status */ Three time fields are maintained for each file The modification time (mtime is when the contents of the file was last modified The changed-status time (ctime) is when the i-node of the file was last modified Many operations (changing the file access permissions, changing the user ID, changing the number of links... ) do affect the i-node without changing the actual content Since the i-node is stored separate from the actual content we need both Note that there is no last-access time for an i-node This is why functions like access(2) and stat(2) do not change any of the three values. Alexander Holupirek (U KN) Files & Directories December, / 57

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu CS@ECNU Operating System Labs Project 3 Oral test Handin your slides Time Project 4 Due: 6 Dec Code Experiment report Operating System Labs Overview of file system File

More information

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell

More information

17: Filesystem Examples: CD-ROM, MS-DOS, Unix

17: Filesystem Examples: CD-ROM, MS-DOS, Unix 17: Filesystem Examples: CD-ROM, MS-DOS, Unix Mark Handley CD Filesystems ISO 9660 Rock Ridge Extensions Joliet Extensions 1 ISO 9660: CD-ROM Filesystem CD is divided into logical blocks of 2352 bytes.

More information

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University File I/O Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O

More information

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell

More information

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories Chapter 4 - Files and Directories Information about files and directories Management of files and directories File Systems Unix File Systems UFS - original FS FFS - Berkeley ext/ext2/ext3/ext4 - Linux

More information

INTRODUCTION TO THE UNIX FILE SYSTEM 1)

INTRODUCTION TO THE UNIX FILE SYSTEM 1) INTRODUCTION TO THE UNIX FILE SYSTEM 1) 1 FILE SHARING Unix supports the sharing of open files between different processes. We'll examine the data structures used by the kernel for all I/0. Three data

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu CS@ECNU Operating System Labs Project 4 (multi-thread & lock): Due: 10 Dec Code & experiment report 18 Dec. Oral test of project 4, 9:30am Lectures: Q&A Project 5: Due:

More information

CS 201. Files and I/O. Gerson Robboy Portland State University

CS 201. Files and I/O. Gerson Robboy Portland State University CS 201 Files and I/O Gerson Robboy Portland State University A Typical Hardware System CPU chip register file ALU system bus memory bus bus interface I/O bridge main memory USB controller graphics adapter

More information

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1 Memory Mapped I/O Michael Jantz Prasad Kulkarni EECS 678 Memory Mapped I/O Lab 1 Introduction This lab discusses various techniques user level programmers can use to control how their process' logical

More information

Contents. NOTICE & Programming Assignment #1. QnA about last exercise. File IO exercise

Contents. NOTICE & Programming Assignment #1. QnA about last exercise. File IO exercise File I/O Examples Prof. Jin-Soo Kim(jinsookim@skku.edu) TA - Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents NOTICE & Programming Assignment

More information

File Systems. q Files and directories q Sharing and protection q File & directory implementation

File Systems. q Files and directories q Sharing and protection q File & directory implementation File Systems q Files and directories q Sharing and protection q File & directory implementation Files and file systems Most computer applications need to Store large amounts of data; larger than their

More information

File Systems. Today. Next. Files and directories File & directory implementation Sharing and protection. File system management & examples

File Systems. Today. Next. Files and directories File & directory implementation Sharing and protection. File system management & examples File Systems Today Files and directories File & directory implementation Sharing and protection Next File system management & examples Files and file systems Most computer applications need to: Store large

More information

Files and Directories Filesystems from a user s perspective

Files and Directories Filesystems from a user s perspective Files and Directories Filesystems from a user s perspective Unix Filesystems Seminar Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of

More information

CS , Spring Sample Exam 3

CS , Spring Sample Exam 3 Andrew login ID: Full Name: CS 15-123, Spring 2010 Sample Exam 3 Mon. April 6, 2009 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the

More information

UNIX System Calls. Sys Calls versus Library Func

UNIX System Calls. Sys Calls versus Library Func UNIX System Calls Entry points to the kernel Provide services to the processes One feature that cannot be changed Definitions are in C For most system calls a function with the same name exists in the

More information

Design Choices 2 / 29

Design Choices 2 / 29 File Systems One of the most visible pieces of the OS Contributes significantly to usability (or the lack thereof) 1 / 29 Design Choices 2 / 29 Files and File Systems What s a file? You all know what a

More information

Important Dates. October 27 th Homework 2 Due. October 29 th Midterm

Important Dates. October 27 th Homework 2 Due. October 29 th Midterm CSE333 SECTION 5 Important Dates October 27 th Homework 2 Due October 29 th Midterm String API vs. Byte API Recall: Strings are character arrays terminated by \0 The String API (functions that start with

More information

The course that gives CMU its Zip! I/O Nov 15, 2001

The course that gives CMU its Zip! I/O Nov 15, 2001 15-213 The course that gives CMU its Zip! I/O Nov 15, 2001 Topics Files Unix I/O Standard I/O A typical hardware system CPU chip register file ALU system bus memory bus bus interface I/O bridge main memory

More information

File I/O. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

File I/O. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University  Embedded Software Lab. 1 File I/O Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Unix files 2 A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O devices are represented

More information

All the scoring jobs will be done by script

All the scoring jobs will be done by script File I/O Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon Han(sanghoon.han@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Announcement (1) All the scoring jobs

More information

File System (FS) Highlights

File System (FS) Highlights CSCI 503: Operating Systems File System (Chapters 16 and 17) Fengguang Song Department of Computer & Information Science IUPUI File System (FS) Highlights File system is the most visible part of OS From

More information

File I/O. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

File I/O. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University File I/O Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O devices

More information

Contents. Programming Assignment 0 review & NOTICE. File IO & File IO exercise. What will be next project?

Contents. Programming Assignment 0 review & NOTICE. File IO & File IO exercise. What will be next project? File I/O Prof. Jin-Soo Kim(jinsookim@skku.edu) TA - Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents Programming Assignment 0 review & NOTICE

More information

CSC 271 Software I: Utilities and Internals

CSC 271 Software I: Utilities and Internals CSC 271 Software I: Utilities and Internals Lecture 13 : An Introduction to File I/O in Linux File Descriptors All system calls for I/O operations refer to open files using a file descriptor (a nonnegative

More information

39. File and Directories

39. File and Directories 39. File and Directories Oerating System: Three Easy Pieces AOS@UC 1 Persistent Storage Kee a data intact even if there is a ower loss. w Hard disk drive w Solid-state storage device Two key abstractions

More information

Contents. NOTICE & Programming Assignment 0 review. What will be next project? File IO & File IO exercise

Contents. NOTICE & Programming Assignment 0 review. What will be next project? File IO & File IO exercise File I/O Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents NOTICE & Programming Assignment 0 review

More information

All the scoring jobs will be done by script

All the scoring jobs will be done by script File I/O Prof. Jinkyu Jeong( jinkyu@skku.edu) TA-Seokha Shin(seokha.shin@csl.skku.edu) TA-Jinhong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

More information

which maintain a name to inode mapping which is convenient for people to use. All le objects are

which maintain a name to inode mapping which is convenient for people to use. All le objects are UNIX Directory Organization UNIX directories are simple (generally ASCII) les which maain a name to inode mapping which is convenient for people to use. All le objects are represented by one or more names

More information

Files and Directories

Files and Directories Files and Directories Stat functions Given pathname, stat function returns structure of information about file fstat function obtains information about the file that is already open lstat same as stat

More information

Lecture 23: System-Level I/O

Lecture 23: System-Level I/O CSCI-UA.0201-001/2 Computer Systems Organization Lecture 23: System-Level I/O Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified) from: Clark Barrett

More information

structs as arguments

structs as arguments Structs A collection of related data items struct record { char name[maxname]; int count; ; /* The semicolon is important! It terminates the declaration. */ struct record rec1; /*allocates space for the

More information

CMPS 105 Systems Programming. Prof. Darrell Long E2.371

CMPS 105 Systems Programming. Prof. Darrell Long E2.371 + CMPS 105 Systems Programming Prof. Darrell Long E2.371 darrell@ucsc.edu + Chapter 3: File I/O 2 + File I/O 3 n What attributes do files need? n Data storage n Byte stream n Named n Non-volatile n Shared

More information

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand File Systems Basics Nima Honarmand File and inode File: user-level abstraction of storage (and other) devices Sequence of bytes inode: internal OS data structure representing a file inode stands for index

More information

Lecture files in /home/hwang/cs375/lecture05 on csserver.

Lecture files in /home/hwang/cs375/lecture05 on csserver. Lecture 5 Lecture files in /home/hwang/cs375/lecture05 on csserver. cp -r /home/hwang/cs375/lecture05. scp -r user@csserver.evansville.edu:/home/hwang/cs375/lecture05. Project 1 posted, due next Thursday

More information

CS631 - Advanced Programming in the UNIX Environment

CS631 - Advanced Programming in the UNIX Environment CS631 - Advanced Programming in the UNIX Environment Slide 1 CS631 - Advanced Programming in the UNIX Environment Files and Directories Department of Computer Science Stevens Institute of Technology Jan

More information

CSci 4061 Introduction to Operating Systems. File Systems: Basics

CSci 4061 Introduction to Operating Systems. File Systems: Basics CSci 4061 Introduction to Operating Systems File Systems: Basics File as Abstraction Naming a File creat/open ( path/name, ); Links: files with multiple names Each name is an alias #include

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the

More information

System- Level I/O. Andrew Case. Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron

System- Level I/O. Andrew Case. Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron System- Level I/O Andrew Case Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron 1 Unix I/O and Files UNIX abstracts many things into files (just a series of bytes) All I/O devices are represented

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto For more information please consult Advanced Programming in the UNIX Environment, 3rd Edition, W. Richard Stevens and

More information

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst Clicker Question #1 For a sequential workload, the limiting factor for a disk system is likely: (A) The speed of

More information

OPERATING SYSTEMS: Lesson 2: Operating System Services

OPERATING SYSTEMS: Lesson 2: Operating System Services OPERATING SYSTEMS: Lesson 2: Operating System Services Jesús Carretero Pérez David Expósito Singh José Daniel García Sánchez Francisco Javier García Blas Florin Isaila 1 Goals To understand what an operating

More information

Linux Forensics. Newbug Tseng Oct

Linux Forensics. Newbug Tseng Oct Linux Forensics Newbug Tseng Oct. 2004. Contents Are u ready Go Real World Exploit Attack Detect Are u ready Linux File Permission OWNER 4 2 1 GROUP 4 2 1 OTHER 4 2 1 R R R W SUID on exection 4000 X W

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Review: RAID 2 RAID o Idea: Build an awesome disk from small, cheap disks o Metrics: Capacity, performance, reliability 3 RAID o Idea:

More information

Last Week: ! Efficiency read/write. ! The File. ! File pointer. ! File control/access. This Week: ! How to program with directories

Last Week: ! Efficiency read/write. ! The File. ! File pointer. ! File control/access. This Week: ! How to program with directories Overview Unix System Programming Directories and File System Last Week:! Efficiency read/write! The File! File pointer! File control/access This Week:! How to program with directories! Brief introduction

More information

System-Level I/O. Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O

System-Level I/O. Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O System-Level I/O Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O A Typical Hardware System CPU chip register file ALU system bus memory bus bus

More information

Automated Test Generation in System-Level

Automated Test Generation in System-Level Automated Test Generation in System-Level Pros + Can be easy to generate system TCs due to clear interface specification + No false alarm (i.e., no assert violation caused by infeasible execution scenario)

More information

The bigger picture. File systems. User space operations. What s a file. A file system is the user space implementation of persistent storage.

The bigger picture. File systems. User space operations. What s a file. A file system is the user space implementation of persistent storage. The bigger picture File systems Johan Montelius KTH 2017 A file system is the user space implementation of persistent storage. a file is persistent i.e. it survives the termination of a process a file

More information

System Calls. Library Functions Vs. System Calls. Library Functions Vs. System Calls

System Calls. Library Functions Vs. System Calls. Library Functions Vs. System Calls System Calls Library Functions Vs. System Calls A library function: Ordinary function that resides in a library external to the calling program. A call to a library function is just like any other function

More information

Systems Programming. 09. Filesystem in USErspace (FUSE) Alexander Holupirek

Systems Programming. 09. Filesystem in USErspace (FUSE) Alexander Holupirek Systems Programming 09. Filesystem in USErspace (FUSE) Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Schedule

More information

File I/O - Filesystems from a user s perspective

File I/O - Filesystems from a user s perspective File I/O - Filesystems from a user s perspective Unix Filesystems Seminar Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz

More information

Advanced Systems Security: Ordinary Operating Systems

Advanced Systems Security: Ordinary Operating Systems Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Advanced Systems Security:

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight HW2 Due Thursday, July 19 th Midterm on Monday, July 23 th 10:50-11:50 in TBD (And regular exercises in between) POSIX

More information

Outline. OS Interface to Devices. System Input/Output. CSCI 4061 Introduction to Operating Systems. System I/O and Files. Instructor: Abhishek Chandra

Outline. OS Interface to Devices. System Input/Output. CSCI 4061 Introduction to Operating Systems. System I/O and Files. Instructor: Abhishek Chandra Outline CSCI 6 Introduction to Operating Systems System I/O and Files File I/O operations File Descriptors and redirection Pipes and FIFOs Instructor: Abhishek Chandra 2 System Input/Output Hardware devices:

More information

System Calls and I/O Appendix. Copyright : University of Illinois CS 241 Staff 1

System Calls and I/O Appendix. Copyright : University of Illinois CS 241 Staff 1 System Calls and I/O Appendix Copyright : University of Illinois CS 241 Staff 1 More System Calls Directory and File System Management s = mkdir(name, mode) Create a new directory s = rmdir(name) s = link(name,

More information

Systems Programming. 08. Standard I/O Library. Alexander Holupirek

Systems Programming. 08. Standard I/O Library. Alexander Holupirek Systems Programming 08. Standard I/O Library Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Last lecture:

More information

File Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

File Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University File Systems Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3044: Operating Systems, Fall 2016, Jinkyu Jeong (jinkyu@skku.edu) File System Layers

More information

Systems Programming/ C and UNIX

Systems Programming/ C and UNIX Systems Programming/ C and UNIX Alice E. Fischer September 9, 2015 Alice E. Fischer Systems Programming Lecture 3... 1/39 September 9, 2015 1 / 39 Outline 1 Compile and Run 2 Unix Topics System Calls The

More information

Files and Directories

Files and Directories Contents 1. Preface/Introduction 2. Standardization and Implementation 3. File I/O 4. Standard I/O Library 5. Files and Directories 6. System Data Files and Information 7. Environment of a Unix Process

More information

Overview. Unix System Programming. Outline. Directory Implementation. Directory Implementation. Directory Structure. Directories & Continuation

Overview. Unix System Programming. Outline. Directory Implementation. Directory Implementation. Directory Structure. Directories & Continuation Overview Unix System Programming Directories & Continuation Maria Hybinette, UGA 1 Last Week: Efficiency read/write The File File pointer File control/access Permissions, Meta Data, Ownership, umask, holes

More information

Operating systems. Lecture 7

Operating systems. Lecture 7 Operating systems. Lecture 7 Michał Goliński 2018-11-13 Introduction Recall Plan for today History of C/C++ Compiler on the command line Automating builds with make CPU protection rings system calls pointers

More information

Preview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call

Preview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call Preview File Descriptors for a Process for Managing Files write read open close lseek A system call is a request for the operating system to do something on behalf of the user's program. The system calls

More information

File System. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

File System. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University. File System Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University msryu@hanyang.ac.kr File Concept Directory Structure File System Structure Allocation Methods Outline 2 2 File Concept

More information

Memento: Time Travel for the Web

Memento: Time Travel for the Web Old Dominion University ODU Digital Commons Computer Science Presentations Computer Science 11-10-2010 Herbert Van de Sompel Michael L. Nelson Old Dominion University, mnelson@odu.edu Robert Sanderson

More information

Files and the Filesystems. Linux Files

Files and the Filesystems. Linux Files Files and the Filesystems Linux Files The file is the most basic and fundamental abstraction in Linux. Linux follows the everything-is-a-file philosophy. Consequently, much interaction occurs via reading

More information

Virtual File System. Don Porter CSE 306

Virtual File System. Don Porter CSE 306 Virtual File System Don Porter CSE 306 History Early OSes provided a single file system In general, system was pretty tailored to target hardware In the early 80s, people became interested in supporting

More information

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O CS162 Operating Systems and Systems Programming Lecture 18 Systems October 30 th, 2017 Prof. Anthony D. Joseph http://cs162.eecs.berkeley.edu Recall: How do we Hide I/O Latency? Blocking Interface: Wait

More information

File and Directories. Advanced Programming in the UNIX Environment

File and Directories. Advanced Programming in the UNIX Environment File and Directories Advanced Programming in the UNIX Environment stat Function #include int stat(const char *restrict pathname, struct stat *restrict buf ); int fstat(int fd, struct stat

More information

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18 I/O & Storage Layers CS162 Operating Systems and Systems Programming Lecture 18 Systems April 2 nd, 2018 Profs. Anthony D. Joseph & Jonathan Ragan-Kelley http://cs162.eecs.berkeley.edu Application / Service

More information

ELEC-C7310 Sovellusohjelmointi Lecture 3: Filesystem

ELEC-C7310 Sovellusohjelmointi Lecture 3: Filesystem ELEC-C7310 Sovellusohjelmointi Lecture 3: Filesystem Risto Järvinen September 21, 2015 Lecture contents Filesystem concept. System call API. Buffered I/O API. Filesystem conventions. Additional stuff.

More information

System-Level I/O Nov 14, 2002

System-Level I/O Nov 14, 2002 15-213 The course that gives CMU its Zip! System-Level I/O Nov 14, 2002 Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O class24.ppt A Typical

More information

HEC POSIX I/O API Extensions Rob Ross Mathematics and Computer Science Division Argonne National Laboratory

HEC POSIX I/O API Extensions Rob Ross Mathematics and Computer Science Division Argonne National Laboratory HEC POSIX I/O API Extensions Rob Ross Mathematics and Computer Science Division Argonne National Laboratory rross@mcs.anl.gov (Thanks to Gary Grider for providing much of the material for this talk!) POSIX

More information

Unix File and I/O. Outline. Storing Information. File Systems. (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu

Unix File and I/O. Outline. Storing Information. File Systems. (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu Outline Unix File and I/O (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu Basics of File Systems Directory and Unix File System: inode UNIX I/O System Calls: open, close, read, write, ioctl File Representations:

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto For more information please consult Advanced Programming in the UNIX Environment, 3rd Edition, W. Richard Stevens and

More information

File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University File Systems Overview Jin-Soo Kim ( jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics File system basics Directory structure File system mounting

More information

CptS 360 (System Programming) Unit 6: Files and Directories

CptS 360 (System Programming) Unit 6: Files and Directories CptS 360 (System Programming) Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2019 Motivation Need to know your way around a filesystem. A properly organized filesystem

More information

Master Calcul Scientifique - Mise à niveau en Informatique Written exam : 3 hours

Master Calcul Scientifique - Mise à niveau en Informatique Written exam : 3 hours Université de Lille 1 Année Universitaire 2015-2016 Master Calcul Scientifique - Mise à niveau en Informatique Written exam : 3 hours Write your code nicely (indentation, use of explicit names... ), and

More information

Thesis, antithesis, synthesis

Thesis, antithesis, synthesis Identity Page 1 Thesis, antithesis, synthesis Thursday, December 01, 2011 4:00 PM Thesis, antithesis, synthesis We began the course by considering the system programmer's point of view. Mid-course, we

More information

File Descriptors and Piping

File Descriptors and Piping File Descriptors and Piping CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 8 Today s topics File Descriptors

More information

A Typical Hardware System The course that gives CMU its Zip! System-Level I/O Nov 14, 2002

A Typical Hardware System The course that gives CMU its Zip! System-Level I/O Nov 14, 2002 class24.ppt 15-213 The course that gives CMU its Zip! System-Level I/O Nov 14, 2002 Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O A Typical

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu cs@ecnu Annoucement Next Monday (28 Sept): We will have a lecture @ 4-302, 15:00-16:30 DON'T GO TO THE LABORATORY BUILDING! TA email update: ecnucchuang@163.com ecnucchuang@126.com

More information

File Systems. CS 450: Operating Systems Sean Wallace Computer Science. Science

File Systems. CS 450: Operating Systems Sean Wallace Computer Science. Science File Systems Science Computer Science CS 450: Operating Systems Sean Wallace What is a file? Some logical collection of data Format/interpretation is (typically) of little concern to

More information

File Input and Output (I/O)

File Input and Output (I/O) File Input and Output (I/O) Brad Karp UCL Computer Science CS 3007 15 th March 2018 (lecture notes derived from material from Phil Gibbons, Dave O Hallaron, and Randy Bryant) 1 Today UNIX I/O Metadata,

More information

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING SOFTWARE ENGINEERING DEPARTMENT

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING SOFTWARE ENGINEERING DEPARTMENT OPERATING SYSTEM LAB #06 & 07 System Calls In UNIX System Call: A system call is just what its name implies a request for the operating system to do something on behalf of the user s program. Process related

More information

UNIX System Programming

UNIX System Programming File I/O 경희대학교컴퓨터공학과 조진성 UNIX System Programming File in UNIX n Unified interface for all I/Os in UNIX ü Regular(normal) files in file system ü Special files for devices terminal, keyboard, mouse, tape,

More information

UNIX FILESYSTEM STRUCTURE BASICS By Mark E. Donaldson

UNIX FILESYSTEM STRUCTURE BASICS By Mark E. Donaldson THE UNIX FILE SYSTEM Under UNIX we can think of the file system as everything being a file. Thus directories are really nothing more than files containing the names of other files and so on. In addition,

More information

Outline. File Systems. File System Structure. CSCI 4061 Introduction to Operating Systems

Outline. File Systems. File System Structure. CSCI 4061 Introduction to Operating Systems Outline CSCI 4061 Introduction to Operating Systems Instructor: Abhishek Chandra File Systems Directories File and directory operations Inodes and metadata Links 2 File Systems An organized collection

More information

Virtual File System. Don Porter CSE 506

Virtual File System. Don Porter CSE 506 Virtual File System Don Porter CSE 506 History ò Early OSes provided a single file system ò In general, system was pretty tailored to target hardware ò In the early 80s, people became interested in supporting

More information

CSCI 4500/8506 Operating Systems Some UNIX System Calls, Library, and PThreads Functions

CSCI 4500/8506 Operating Systems Some UNIX System Calls, Library, and PThreads Functions CSCI 4500/8506 Operating Systems Some UNIX System Calls, Library, and PThreads Functions Described below is a subset of UNIX system calls, library functions, and Pthreads (that is, POSIX Threads) functions.

More information

The UNIX File System

The UNIX File System The UNIX File System Magnus Johansson May 9, 2007 1 UNIX file system A file system is created with mkfs. It defines a number of parameters for the system, such as: bootblock - contains a primary boot program

More information

FILE SYSTEMS. Tanzir Ahmed CSCE 313 Fall 2018

FILE SYSTEMS. Tanzir Ahmed CSCE 313 Fall 2018 FILE SYSTEMS Tanzir Ahmed CSCE 313 Fall 2018 References Previous offerings of the same course by Prof Tyagi and Bettati Textbook: Operating System Principles and Practice 2 The UNIX File System File Systems

More information

The UNIX File System

The UNIX File System The UNIX File System Magnus Johansson (May 2007) 1 UNIX file system A file system is created with mkfs. It defines a number of parameters for the system as depicted in figure 1. These paremeters include

More information

File Types in Unix. Regular files which include text files (formatted) and binary (unformatted)

File Types in Unix. Regular files which include text files (formatted) and binary (unformatted) File Management Files can be viewed as either: a sequence of bytes with no structure imposed by the operating system. or a structured collection of information with some structure imposed by the operating

More information

File I/0. Advanced Programming in the UNIX Environment

File I/0. Advanced Programming in the UNIX Environment File I/0 Advanced Programming in the UNIX Environment File Descriptors Created and managed by the UNIX kernel. Created using open or creat system call. Used to refer to an open file UNIX System shells

More information

FILE SYSTEMS. Jo, Heeseung

FILE SYSTEMS. Jo, Heeseung FILE SYSTEMS Jo, Heeseung TODAY'S TOPICS File system basics Directory structure File system mounting File sharing Protection 2 BASIC CONCEPTS Requirements for long-term information storage Store a very

More information

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls Lecture 3 Introduction to Unix Systems Programming: Unix File I/O System Calls 1 Unix File I/O 2 Unix System Calls System calls are low level functions the operating system makes available to applications

More information

Lecture 21 Systems Programming in C

Lecture 21 Systems Programming in C Lecture 21 Systems Programming in C A C program can invoke UNIX system calls directly. A system call can be defined as a request to the operating system to do something on behalf of the program. During

More information

Systems Programming. COSC Software Tools. Systems Programming. High-Level vs. Low-Level. High-Level vs. Low-Level.

Systems Programming. COSC Software Tools. Systems Programming. High-Level vs. Low-Level. High-Level vs. Low-Level. Systems Programming COSC 2031 - Software Tools Systems Programming (K+R Ch. 7, G+A Ch. 12) The interfaces we use to work with the operating system In this case: Unix Programming at a lower-level Systems

More information

System- Level I/O. CS 485 Systems Programming Fall Instructor: James Griffioen

System- Level I/O. CS 485 Systems Programming Fall Instructor: James Griffioen System- Level I/O CS 485 Systems Programming Fall 2015 Instructor: James Griffioen Adapted from slides by R. Bryant and D. O Hallaron (hip://csapp.cs.cmu.edu/public/instructors.html) 1 Today Unix I/O Metadata,

More information

Advanced Unix/Linux System Program. Instructor: William W.Y. Hsu

Advanced Unix/Linux System Program. Instructor: William W.Y. Hsu Advanced Unix/Linux System Program Instructor: William W.Y. Hsu CONTENTS File I/O, File Sharing 3/15/2018 INTRODUCTION TO COMPETITIVE PROGRAMMING 2 Recall simple-cat.c... /* * Stripped down version of

More information