CSCI 347 Test 2 Review: Files and Directories
16 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which system call is used to create a new process?

  • wait
  • fork (correct)
  • exec
  • pid
  • What is the purpose of the umask access?

  • To create hard links between files
  • To rename a file
  • To set default permissions for new files and directories (correct)
  • To change the ownership of a file
  • What does the /etc/passwd file contain?

  • A list of system users (correct)
  • A list of system processes
  • A list of system files
  • A list of system groups
  • What is the purpose of the setbuf function?

    <p>To set the buffering mode</p> Signup and view all the answers

    What is a zombie process?

    <p>A process that has terminated but its parent has not waited for it</p> Signup and view all the answers

    What is the purpose of the readdir function?

    <p>To read from a directory</p> Signup and view all the answers

    What is the purpose of the inode in a UNIX file system?

    <p>To store the file name and its associated metadata</p> Signup and view all the answers

    What is the effect of setting the Set UID bit on a file?

    <p>The file is executed with the owner's permissions</p> Signup and view all the answers

    What is the purpose of the dirname function in the Standard I/O Library?

    <p>To get the directory name from a file path</p> Signup and view all the answers

    What is the significance of the /etc/group file?

    <p>It stores information about system groups</p> Signup and view all the answers

    What is the purpose of the gettimeofday function?

    <p>To get the current system time</p> Signup and view all the answers

    What is the result of calling the fork function?

    <p>A new process is created and the parent process continues</p> Signup and view all the answers

    What is the purpose of the waitpid function?

    <p>To wait for a child process to terminate</p> Signup and view all the answers

    What is the purpose of the pipe function in interprocess communication?

    <p>To establish a communication channel between processes</p> Signup and view all the answers

    What is the purpose of the chmod function?

    <p>To change the file permissions</p> Signup and view all the answers

    What is the significance of the utimes function?

    <p>It sets the file modification time</p> Signup and view all the answers

    Study Notes

    Files and Directories

    • A UNIX file system consists of disk partitions
    • File types and directory entries are stored as (name, inode-number) pairs
    • Links can be hard (inode: data stored and access to file data via direct and indirect blocks) or symbolic
    • Ownership of a file can be viewed using stat, fstat, and lstat commands, with permissions for user/group/other
    • Set UID and Set GID bits can be set, and access control can be modified using umask, chmod, and fchmod commands
    • Files can be managed using chown, fchown, link, unlink, rename, and utimes commands
    • Directories can be managed using mkdir, rmdir, chdir, and fchdir commands
    • File descriptors can be manipulated using opendir, closedir, readdir, telldir, seekdir, and rewinddir commands

    Standard I/O Library

    • Standard input, output, and error streams (stdin, stdout, stderr) can be buffered, line-buffered, or unbuffered
    • Files can be opened using fopen, freopen, and fdopen commands
    • Buffering modes can be set using setbuf and setvbuf commands
    • File input/output can be performed using fgetc, ferror, feof, clearerr, and ungetc commands
    • Formatted input/output can be performed using fgets, fputs, and printf commands
    • Binary input/output can be performed using fread, fwrite, ftell, fseek, fgetpos, and fsetpos commands

    System Information

    • /etc/passwd and /etc/group files store user and group information
    • User and group information can be retrieved using getpwuid, getpwnam, getpwent, setpwent, and endpwent commands
    • Supplementary Group IDs can be used to add groups to a user
    • /etc directory stores system information
    • uname(1) and uname(3) commands provide system information
    • Time-related functions include time, ctime, strftime, gettimeofday, and others
    • Time zone issues can be handled using certain functions

    Process Control

    • Process ID (pid) and group ID (gid) can be used to manage processes
    • fork function creates a new process, and exit function terminates a process
    • wait and waitpid system calls can be used to wait for a process to terminate
    • WIFEXITED() and WEXITSTATUS() macros provide exit status information
    • Zombie processes can be terminated using wait, waitpid, wait3, and wait4 commands

    Pipes

    • Pipes enable interprocess communication
    • Kernel pipe, pipe(2) system call creates a pipe
    • Pipes have read and write ends
    • Termination conditions include EOF on read and SIGPIPE on write
    • One-way communication can be achieved from child to parent, or parent to child using pipes
    • popen(3) and pclose(3) commands can be used to create and manage pipes
    • micro shell concepts include exit values, expansion, environment variables, builtin commands, shell scripts, and script arguments

    Files and Directories

    • A UNIX file system consists of disk partitions
    • File types and directory entries are stored as (name, inode-number) pairs
    • Links can be hard (inode: data stored and access to file data via direct and indirect blocks) or symbolic
    • Ownership of a file can be viewed using stat, fstat, and lstat commands, with permissions for user/group/other
    • Set UID and Set GID bits can be set, and access control can be modified using umask, chmod, and fchmod commands
    • Files can be managed using chown, fchown, link, unlink, rename, and utimes commands
    • Directories can be managed using mkdir, rmdir, chdir, and fchdir commands
    • File descriptors can be manipulated using opendir, closedir, readdir, telldir, seekdir, and rewinddir commands

    Standard I/O Library

    • Standard input, output, and error streams (stdin, stdout, stderr) can be buffered, line-buffered, or unbuffered
    • Files can be opened using fopen, freopen, and fdopen commands
    • Buffering modes can be set using setbuf and setvbuf commands
    • File input/output can be performed using fgetc, ferror, feof, clearerr, and ungetc commands
    • Formatted input/output can be performed using fgets, fputs, and printf commands
    • Binary input/output can be performed using fread, fwrite, ftell, fseek, fgetpos, and fsetpos commands

    System Information

    • /etc/passwd and /etc/group files store user and group information
    • User and group information can be retrieved using getpwuid, getpwnam, getpwent, setpwent, and endpwent commands
    • Supplementary Group IDs can be used to add groups to a user
    • /etc directory stores system information
    • uname(1) and uname(3) commands provide system information
    • Time-related functions include time, ctime, strftime, gettimeofday, and others
    • Time zone issues can be handled using certain functions

    Process Control

    • Process ID (pid) and group ID (gid) can be used to manage processes
    • fork function creates a new process, and exit function terminates a process
    • wait and waitpid system calls can be used to wait for a process to terminate
    • WIFEXITED() and WEXITSTATUS() macros provide exit status information
    • Zombie processes can be terminated using wait, waitpid, wait3, and wait4 commands

    Pipes

    • Pipes enable interprocess communication
    • Kernel pipe, pipe(2) system call creates a pipe
    • Pipes have read and write ends
    • Termination conditions include EOF on read and SIGPIPE on write
    • One-way communication can be achieved from child to parent, or parent to child using pipes
    • popen(3) and pclose(3) commands can be used to create and manage pipes
    • micro shell concepts include exit values, expansion, environment variables, builtin commands, shell scripts, and script arguments

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Review of chapters 4, 5, 6, 8, and 15 for CSCI 347 Test 2, covering topics like files and directories, UNIX file system, and disk partitions.

    More Like This

    File System Implementation Quiz
    10 questions
    Operating System Concepts: Virtual File Systems
    18 questions
    GFS and GFS2 File Systems
    18 questions

    GFS and GFS2 File Systems

    RetractableMaxwell6001 avatar
    RetractableMaxwell6001
    Use Quizgecko on...
    Browser
    Browser