Files and Directories Filesystems from a user s perspective
|
|
- Angela Harvey
- 5 years ago
- Views:
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 20. November 2007 Alexander Holupirek (U KN) Files & Directories 20. November / 41
2 Introduction Introduction Last session: I/O for regular files. opening, reading, writing a file. Today: Additional features of the filesystem. Properties of a file. The stat functions. Members of the stat structure. Next: The structure of a Unix filesystem. Symbolic links. Functions that operate on directories. The standard I/O library no seminar Alexander Holupirek (U KN) Files & Directories 20. November / 41
3 Synopsis of the stat functions The functions stat(2), fstat(2), and lstat(2) # include <sys / types.h> # include <sys / stat.h> int stat ( const char * path, struct stat * sb ); int fstat ( int fd, struct stat * sb ); int lstat ( const char * path, struct stat * sb ); Given a path, the stat(2) function returns a structure of information about the named file. fstat(2) works with a file descriptor, instead of a pathname. lstat(2) returns information about the symbolic link, not the referrenced file. Alexander Holupirek (U KN) Files & Directories 20. November / 41
4 The stat struct The stat family The structure struct stat { 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 */ u_int32_t st_flags ; /* user defined flags for file */ u_int32_t st_gen ; /* file generation number */ }; This is where ls -l gets its information from. Mostly primitive system data types. Alexander Holupirek (U KN) Files & Directories 20. November / 41
5 File types The stat family File types - st mode (15-12) struct stat { mode_t st_mode ; /* inode s mode */ }; The type of a file is encoded in the st mode member of the stat structure. Regular file Text and binary data. Directory file Names of files and pointers to information on these files. Character special file Certain type of devices. Block special file Typically disk devices. FIFO Used for IPC (aka pipes). Socket Network communication. Symbolic link Pointer to another file. Alexander Holupirek (U KN) Files & Directories 20. November / 41
6 File type definition The stat family File types - st mode (15-12) struct stat { mode_t st_mode ; /* inode s mode */ }; sys / types. h : typedef mode_t mode_t ; sys / _types. h: typedef uint32_t mode_t ; /* sys / stat.h ( OpenBSD 4.2) */ # define S_IFMT /* type of file mask */ # define S_IFIFO /* named pipe ( fifo ) */ # define S_IFCHR /* character special */ # define S_IFDIR /* directory */ # define S_IFBLK /* block special */ # define S_IFREG /* regular */ # define S_IFLNK /* symbolic link */ # define S_IFSOCK /* socket */ Alexander Holupirek (U KN) Files & Directories 20. November / 41
7 File type determination The stat family File types - st mode (15-12) Determine file types with macros (pass st mode as argument). Macro Type of file S ISREG(m) Regular file S ISDIR(m) Directory file S ISCHR(m) Character special file S ISBLK(m) Block special file S ISFIFO(m) FIFO S ISLNK(m) Socket S ISSOCK(m) Symbolic link Tabelle: File type macros in <sys/stat.h> Alexander Holupirek (U KN) Files & Directories 20. November / 41
8 File types and macros The stat family File types - st mode (15-12) File types: /* sys / stat.h ( OpenBSD 4.2) */ # define S_IFMT /* type of file mask */ # define S_IFIFO /* named pipe ( fifo ) */ # define S_IFCHR /* character special */ # define S_IFDIR /* directory */ # define S_IFBLK /* block special */ # define S_IFREG /* regular */ # define S_IFLNK /* symbolic link */ # define S_IFSOCK /* socket */ File type macros: # define S_ISFIFO ( m) (( m & ) == ) /* fifo */ # define S_ISCHR ( m) (( m & ) == ) /* char special */ # define S_ISDIR ( m) (( m & ) == ) /* directory */ # define S_ISBLK ( m) (( m & ) == ) /* block special */ # define S_ISREG ( m) (( m & ) == ) /* regular file */ # define S_ISLNK ( m) (( m & ) == ) /* symbolic link */ # define S_ISSOCK ( m) (( m & ) == ) /* socket */ Alexander Holupirek (U KN) Files & Directories 20. November / 41
9 Used bits in st mode so far The stat family File types - st mode (15-12) What we have so far: # define S_IFIFO /* named pipe ( fifo ) */ # define S_IFCHR /* character special */ # define S_IFDIR /* directory */ # define S_IFBLK /* block special */ # define S_IFREG /* regular */ # define S_IFLNK /* symbolic link */ # define S_IFSOCK /* socket */ # define S_IFMT /* type of file mask */ --x xxx /* used bits st_mode */ m ode Alexander Holupirek (U KN) Files & Directories 20. November / 41
10 File permissions The stat family File permissions - st mode (11-0) /* sys / stat.h ( OpenBSD 4.2) */ # define S_IRWXU /* RWX mask for owner */ # define S_IRUSR /* R for owner */ # define S_IWUSR /* W for owner */ # define S_IXUSR /* X for owner */ # define S_IRWXG /* RWX mask for group */ # define S_IRGRP /* R for group */ # define S_IWGRP /* W for group */ # define S_IXGRP /* X for group */ # define S_IRWXO /* RWX mask for other */ # define S_IROTH /* R for other */ # define S_IWOTH /* W for other */ # define S_IXOTH /* X for other */ # define S_IREAD S_IRUSR # define S_IWRITE S_IWUSR # define S_IEXEC S_IXUSR Alexander Holupirek (U KN) Files & Directories 20. November / 41
11 Used bits in st mode so far The stat family File permissions - st mode (11-0) Missing bits 8-0: # define S_IRWXO /* RWX mask for other */ # define S_IRWXG /* RWX mask for group */ # define S_IRWXU /* RWX mask for owner */ # define S_IFMT /* type of file mask */ --x xxx --- xxx xxx xxx /* used bits st_mode */ m ode usr grp oth Alexander Holupirek (U KN) Files & Directories 20. November / 41
12 File ownership The stat family File ownership, st mode, st uid, st gid struct stat { mode_t st_mode ; /* inode s mode */ uid_t st_uid ; /* user ID of owner */ gid_t st_gid ; /* group ID of owner */ }; Every file has an owner and a group owner. The owner is stored in member st uid, the group in st gid. Alexander Holupirek (U KN) Files & Directories 20. November / 41
13 Process IDs The stat family Process IDs and their relation to stat Every process has some associated IDs: real user ID who we really are real group ID effective user ID effective group ID used for file access permission checks supplementary group IDs saved set-user-id saved by exec functions saved set-group-id real [user group] ID taken from password file on login. eff. [user group] ID depends on set-[user group]-id bits in st mode. supplementary group ID taken from /etc/group on login (max 16 grps). saved set-[user group]-id copies of eff. [user group] IDs. Alexander Holupirek (U KN) Files & Directories 20. November / 41
14 The set-id bits The stat family Process IDs and their relation to stat The missing bits 11 and 10: # define S_ISGID /* set group id on exec */ # define S_ISUID /* set user id on exec */ --x xxx xx - xxx xxx xxx /* used bits st_mode */ m ode ss - usr grp oth When we execute a program file the effective user ID of the process is usually the real user ID and the effective group ID is usually the real group ID. But, there are two special flags in the file s mode word (st mode). Set-user-ID (S ISUID) and set-group-id (S ISGID).... when this file is executed, set the effective user ID of the process to be the owner of the file (st uid). Alexander Holupirek (U KN) Files & Directories 20. November / 41
15 Example for set-user-id The stat family Process IDs and their relation to stat Example Consider passwd(1) to modify a user s password $ ls -l / usr / bin / passwd -r-sr -xr -x 1 root bin Aug 28 18:12 / usr / bin / passwd Owner is root and set-user-id bit is set. When the program file is running as a process, it has superuser privileges. This is independent of the real user ID of the process that executes the file. This is required to wirte to the password file/db. Alexander Holupirek (U KN) Files & Directories 20. November / 41
16 File access tests File access tests performed by the kernel Input: effuid - effective user id of the process Input: st uid - user id of the file Output: access ok, access deny begin if effuid equals 0 then return ok else if effuid equals st uid then if apt user permission then return ok else return deny; else if effuid equals st gid then if apt group permission then return ok else return deny; else if apt other permission then return ok else return deny; end end Alexander Holupirek (U KN) Files & Directories 20. November / 41
17 File access permissions quiz File access permissions Do any file types have permissions? Alexander Holupirek (U KN) Files & Directories 20. November / 41
18 File access permissions quiz File access permissions Do any file types have permissions? Yes. Any file types have permission (not only regular files). Alexander Holupirek (U KN) Files & Directories 20. November / 41
19 File access permissions quiz File access permissions Do any file types have permissions? Yes. Any file types have permission (not only regular files). What does execute permission for a directory grant? Alexander Holupirek (U KN) Files & Directories 20. November / 41
20 File access permissions quiz File access permissions Do any file types have permissions? Yes. Any file types have permission (not only regular files). What does execute permission for a directory grant? Permission to pass through the directory when it is a component of a pathname that we are trying to access (i.e., search the directory looking for a specific filename). Alexander Holupirek (U KN) Files & Directories 20. November / 41
21 File access permissions quiz File access permissions Do any file types have permissions? Yes. Any file types have permission (not only regular files). What does execute permission for a directory grant? Permission to pass through the directory when it is a component of a pathname that we are trying to access (i.e., search the directory looking for a specific filename). What is the search bit? Where does its name come from? Alexander Holupirek (U KN) Files & Directories 20. November / 41
22 File access permissions quiz File access permissions Do any file types have permissions? Yes. Any file types have permission (not only regular files). What does execute permission for a directory grant? Permission to pass through the directory when it is a component of a pathname that we are trying to access (i.e., search the directory looking for a specific filename). What is the search bit? Where does its name come from? Whenever we want to open any file by name we must have execute permission in each directory mentioned in the name (including the current directory if it is implied). This is why the execute permission bit for the directory is often called the search bit. Alexander Holupirek (U KN) Files & Directories 20. November / 41
23 File access permissions quiz File access permissions What does read permission for a directory grant? Alexander Holupirek (U KN) Files & Directories 20. November / 41
24 File access permissions quiz File access permissions What does read permission for a directory grant? Obtain a listing of all filenames in the directory. Alexander Holupirek (U KN) Files & Directories 20. November / 41
25 File access permissions quiz File access permissions What does read permission for a directory grant? Obtain a listing of all filenames in the directory. To create a new file what permissions do we need in the directory? Alexander Holupirek (U KN) Files & Directories 20. November / 41
26 File access permissions quiz File access permissions What does read permission for a directory grant? Obtain a listing of all filenames in the directory. To create a new file what permissions do we need in the directory? We can not create a new file in a directory unless we have write and execute permission in the directory. Alexander Holupirek (U KN) Files & Directories 20. November / 41
27 File access permissions quiz File access permissions What does read permission for a directory grant? Obtain a listing of all filenames in the directory. To create a new file what permissions do we need in the directory? We can not create a new file in a directory unless we have write and execute permission in the directory. To delete an existing file what permissions do we need in the directory? Alexander Holupirek (U KN) Files & Directories 20. November / 41
28 File access permissions quiz File access permissions What does read permission for a directory grant? Obtain a listing of all filenames in the directory. To create a new file what permissions do we need in the directory? We can not create a new file in a directory unless we have write and execute permission in the directory. To delete an existing file what permissions do we need in the directory? We (also) need write and execute permission in the directory containing the file. Alexander Holupirek (U KN) Files & Directories 20. November / 41
29 File access permissions quiz File access permissions What does read permission for a directory grant? Obtain a listing of all filenames in the directory. To create a new file what permissions do we need in the directory? We can not create a new file in a directory unless we have write and execute permission in the directory. To delete an existing file what permissions do we need in the directory? We (also) need write and execute permission in the directory containing the file. Do we need to have read and write permissions on the file to delete it? Alexander Holupirek (U KN) Files & Directories 20. November / 41
30 File access permissions quiz File access permissions What does read permission for a directory grant? Obtain a listing of all filenames in the directory. To create a new file what permissions do we need in the directory? We can not create a new file in a directory unless we have write and execute permission in the directory. To delete an existing file what permissions do we need in the directory? We (also) need write and execute permission in the directory containing the file. Do we need to have read and write permissions on the file to delete it? No. Alexander Holupirek (U KN) Files & Directories 20. November / 41
31 The history of the sticky bit File access permissions The missing bits 9: # define S_ISTXT /* sticky bit */ --x xxx xxx xxx xxx xxx /* used bits st_mode */ m ode sst usr grp oth The S ISTXT aka S VTX is known as sticky bit. On earlier versions of Unix it had an effect on executable programs. If set, a copy of the program s text was saved in the swap area on process termination. This caused the program to load into memory faster the next time. Swap area was handled as a contiguous file, compared to random data blocks in fs. S ISVTX as mnemonic for saved-text bit. Obsoleted by virtual memory and faster filesystems. Alexander Holupirek (U KN) Files & Directories 20. November / 41
32 The sticky bit today - S ISTXT File access permissions Today it has an effect on directories. If set for a directory, a file in the directory can be removed or renamed only if the user has write permission for the directory, and either owns the file, owns the directory, or is the superuser /tmp is a good candidate for the sticky bit. Any user can typically create files there. drwxrwxrwt 7 root root 4.0K :46 tmp But users should not be able to delete or rename files owned by others. Alexander Holupirek (U KN) Files & Directories 20. November / 41
33 File access permissions Functions related to st mode, st uid, st gid access(2) - check access permissions of a file or pathname umask(2) - set file creation mode mask chmod, fchmod(2) - change mode of file chown, fchown, lchown(2) - change owner/group of a file or link Alexander Holupirek (U KN) Files & Directories 20. November / 41
34 Lecture Material The tutorials are based on the following material W. Richard Stevens. Advanced Programming in the UNIX Environment. ISBN , 1999, 19th Printing. Addison-Wesley Professional Computing Series. The OpenBSD Developers. OpenBSD Manual Pages (Release 4.1). ISBN Marshall K. McKusick, Keith Bostic, Michael J. Karels, John S. Quarterman. The Design and Implementation of the 4.4BSD Operating System. ISBN , 1996, Addison-Wesley. Alexander Holupirek (U KN) Files & Directories 20. November / 41
35 Seminar Talks Lecture Material Database Driven Filesystems Patrice Matthias Brendamour, Markus Majer Survey, WinFS, BeOS and Spotlight FS Stackable FS Bastian Lemke: Stackable FS from the beginning Jochen Oekonomopulos: FiST on various platforms, Stackable FS stubs in *BSD Alexander Holupirek (U KN) Files & Directories 20. November / 41
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 informationCSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19
CSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19 User and Group IDs Ref: Chapter 3 of [HGS]. Each user is given an ID (integer) called uid. (Most system programs use uid instead of the
More informationSystem 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 informationCS631 - 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 information17: 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 informationFiles 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 informationChapter 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 informationOriginal ACL related man pages
Original ACL related man pages NAME getfacl - get file access control lists SYNOPSIS getfacl [-drlpvh] file... getfacl [-drlpvh] - DESCRIPTION For each file, getfacl displays the file name, owner, the
More informationHyo-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 informationI/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 informationFiles 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 informationFiles 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 informationI/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 informationf90 unix file: Unix File Operations Module March 9, 2009
f90 unix file: Unix File Operations Module March 9, 2009 1 Name f90 unix file Module of Unix file operations 2 Usage USE F90 UNIX FILE This module contains part of a Fortran API to functions detailed in
More informationCSC 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 informationFile 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 informationMemory 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 informationFiles and Directories Objectives Additional Features of the File System Properties of a File. Three major functions that return file information:
Files and Directories Objectives Additional Features of the File System Properties of a File. Three major functions that return file information: #include #include int stat(const
More informationCSci 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 informationFile 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 informationLinux C C man mkdir( ) mkdir Linux man mkdir mkdir( ) mkdir mkdir( )
D Linux Linux E-D.1 Linux C C man mkdir( ) mkdir Linux man mkdir mkdir( ) mkdir mkdir( ) jhchen@aho:~$ man -S 2 mkdir Reformatting mkdir(2), please wait... MKDIR(2) Linux Programmer's Manual MKDIR(2) NAME
More informationContents. 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 informationUNIX 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 informationwhich 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 informationFiles and directories. Updated by: Dr. Safwan Qasem Spring 2010 Original version created by: Dr. Mohamed El Bachir Menai
Files and directories Updated by: Dr. Safwan Qasem Spring 2010 Original version created by: Dr. Mohamed El Bachir Menai 1 Files and Directories Objectives Additional Features of the File System Properties
More informationFile 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 informationUNIX 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 informationOperating 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 informationCS , 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 informationHomework 5. Due Date: Friday, June 7, 2002, at 11:59PM; no late assignments accepted Points: 100
Homework 5 Due Date: Friday, June 7, 2002, at 11:59PM; no late assignments accepted Points: 100 UNIX System 1. (10 points) I want to make the file libprog.a in my home directory available to everyone so
More informationRicardo 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 informationCS 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 informationDesign 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 informationThe 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 informationLecture 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 informationSystems 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 informationPreview. lseek System Calls. A File Copy 9/18/2017. An opened file offset can be explicitly positioned by calling lseek system call.
Preview lseek System Calls lseek() System call File copy dup() and dup2() System Cal Command Line Argument sat, fsat, lsat system Call ID s for a process File Access permission access System Call umask
More informationFiles (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1
Files (review) and Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 midterms (Feb 11 and April 1) Files and Permissions Regular Expressions 2 Sobel, Chapter 6 160_pathnames.html
More informationThesis, 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 informationAdvanced 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 informationCptS 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 informationContents. 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 informationAutomated 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 informationCSCI-E28 Lecture 3 Outline. Directories, File Attributes, Bits, File Operations. Write our own versions of Unix programs
CSCI-E28 Lecture 3 Outline Topics: Approach: Directories, File Attributes, Bits, File Operations Write our own versions of Unix programs Featured Commands: ls, ls -l Main Ideas: Adirectory is a list of
More informationContents. 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 informationFile 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 informationFile 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 informationSystem- 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 informationFiles and Directories E. Im
Files and Directories 2009 E. Im 1 How to write the ls program? Is this a directory? Permissions for the owner Permissions for the members of the owner group group Symbolic links ($ln -s RigidBodyWin.h
More informationFile 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 informationLecture 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 informationstructs 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 informationLinux 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 informationOperating 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 information5/8/2012. Encryption-based Protection. Protection based on Access Permission (Contd) File Security, Setting and Using Permissions Chapter 9
File Security, Setting and Using Permissions Chapter 9 To show the three protection and security mechanisms that UNIX provides To describe the types of users of a UNIX file To discuss the basic operations
More informationNote: Before using this information and the product it supports, read the information in Notices.
Note: Before using this information and the product it supports, read the information in Notices. Copyright IBM Corporation 2003, 2011. US Government Users Restricted Rights Use, duplication or disclosure
More informationFile 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 informationAll 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 informationImportant 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 informationUNIT I INTRODUCTION TO UNIX & FILE SYSTEM
INTRODUCTION TO UNIX & FILE SYSTEM Part A 1. What is UNIX? UNIX(Uniplexed Information Computing System) it is an operating system was developed in Early 1970 at Bell Labs. It was initially a character
More informationParents and Children
1 Process Identifiers Every process apart from the PID also has a PUID and a PGID. There are two types of PUID and PGID: real and effective. The real PUID is always equal to the user running the process
More informationAll 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 informationLecture 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 informationSystem-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 informationFile 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 informationLecture 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 informationSystem 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 informationOutline. 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 informationCS 33. Files Part 2. CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.
CS 33 Files Part 2 CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. Directories unix etc home pro dev passwd motd twd unix... slide1 slide2 CS33 Intro to Computer
More informationCMPSC 311- Introduction to Systems Programming Module: Input/Output
CMPSC 311- Introduction to Systems Programming Module: Input/Output Professor Patrick McDaniel Fall 2014 Input/Out Input/output is the process of moving bytes into and out of the process space. terminal/keyboard
More informationAdvanced Programming in the UNIX Environment W. Richard Stevens
Advanced Programming in the UNIX Environment W. Richard Stevens ADDISON-WESLEY PUBLISHING COMPANY Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam
More informationOperating system security models
Operating system security models Unix security model Windows security model MEELIS ROOS 1 General Unix model Everything is a file under a virtual root diretory Files Directories Sockets Devices... Objects
More informationbash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1
bash startup files Linux/Unix files stty Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 midterms (Feb 27 and April 10) bash startup files More Linux Files review stty 2 We customize our
More informationPreview. 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 informationProcesses are subjects.
Identification and Authentication Access Control Other security related things: Devices, mounting filesystems Search path TCP wrappers Race conditions NOTE: filenames may differ between OS/distributions
More informationMemento: 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 informationPOSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017
Linux/UNIX IPC Programming POSIX Shared Memory Michael Kerrisk, man7.org c 2017 mtk@man7.org November 2017 Outline 10 POSIX Shared Memory 10-1 10.1 Overview 10-3 10.2 Creating and opening shared memory
More informationELEC-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 informationMaster 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 informationPrivileges: who can control what
Privileges: who can control what Introduction to Unix May 24, 2008, Morocco Hervey Allen Goal Understand the following: The Unix security model How a program is allowed to run Where user and group information
More informationOperating Systems Lab
Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 4 Paths, Links & File Permissions
More informationSystems 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 informationUNIX File Hierarchy: Structure and Commands
UNIX File Hierarchy: Structure and Commands The UNIX operating system organizes files into a tree structure with a root named by the character /. An example of the directory tree is shown below. / bin
More informationContents. IPC (Inter-Process Communication) Representation of open files in kernel I/O redirection Anonymous Pipe Named Pipe (FIFO)
Pipes and FIFOs Prof. Jin-Soo Kim( jinsookim@skku.edu) TA JinHong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents IPC (Inter-Process Communication)
More informationRTEMS Filesystem Design Guide
RTEMS Filesystem Design Guide Edition 1, for RTEMS 4.5.0-beta3 May 2000 On-Line Applications Research Corporation On-Line Applications Research Corporation TEXinfo 1999-09-25.10 COPYRIGHT c 1988-2000.
More informationProcesses are subjects.
Identification and Authentication Access Control Other security related things: Devices, mounting filesystems Search path Race conditions NOTE: filenames may differ between OS/distributions Principals
More informationSystem-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 informationUnix System Calls. Gwan-Hwan Hwang Dept. CSIE National Taiwan Normal University
Unix System Calls Gwan-Hwan Hwang Dept. CSIE National Taiwan Normal University 2006.12.25 UNIX System Overview UNIX Architecture Login Name Shells Files and Directories File System Filename Pathname Working
More informationlsx [ls_options ] [names]
NAME ls, lc, l, ll, lsf, lsr, lsx - list contents of directories SYNOPSIS ls [-abcdefgilmnopqrstuxacfhlr1] [names] lc [-abcdefgilmnopqrstuxacfhlr1] [names] l [ls_options ] [names] ll [ls_options ] [names]
More informationFile 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 informationDiscretionary Access Control
Operating System Security Discretionary Seong-je Cho ( 조성제 ) (sjcho at dankook.ac.kr) Fall 2018 Computer Security & Operating Systems Lab, DKU - 1-524870, F 18 Discretionary (DAC) Allows the owner of the
More informationAccess Control. CMPSC Spring 2012 Introduction Computer and Network Security Professor Jaeger.
Access Control CMPSC 443 - Spring 2012 Introduction Computer and Network Security Professor Jaeger www.cse.psu.edu/~tjaeger/cse443-s12/ Access Control Describe the permissions available to computing processes
More informationProject 5 File System Protection
Project 5 File System Protection Introduction This project will implement simple protection in the xv6 file system. Your goals are to: 1. Implement protection in the xv6 file system. 2. Understand how
More information412 Notes: Filesystem
412 Notes: Filesystem A. Udaya Shankar shankar@cs.umd.edu December 5, 2012 Contents 1 Filesystem interface 2 2 Filesystem implementation 3 3 FAT (mostly from Wikepedia) 5 4 UFS (mostly from Wikepedia)
More informationIntroduction to Computer Security
Introduction to Computer Security UNIX Security Pavel Laskov Wilhelm Schickard Institute for Computer Science Genesis: UNIX vs. MULTICS MULTICS (Multiplexed Information and Computing Service) a high-availability,
More informationA 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 informationINTRODUCTION 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 informationCS/CIS 249 SP18 - Intro to Information Security
Lab assignment CS/CIS 249 SP18 - Intro to Information Security Lab #2 - UNIX/Linux Access Controls, version 1.2 A typed document is required for this assignment. You must type the questions and your responses
More informationUNIX SYSTEM PROGRAMMING
UNIX SYSTEM PROGRAMMING Subject Code: I.A. Marks : 25 Hours/Week : 04 Exam Hours: 03 Total Hours : 52 Exam Marks: 100 PART A UNIT 1 6 Hours Introduction: UNIX and ANSI Standards: The ANSI C Standard, The
More informationProgrammation Système Cours 4 IPC: FIFO
Programmation Système Cours 4 IPC: FIFO Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot 2014 2015 URL http://upsilon.cc/zack/teaching/1415/progsyst/ Copyright
More information