Game Syscalls Flashcards

Game Syscalls Flashcards

Assessment

Flashcard

Computers

University

Practice Problem

Hard

Created by

Petronela Vieru

FREE Resource

Student preview

quiz-placeholder

8 questions

Show all answers

1.

FLASHCARD QUESTION

Front

Media Image

Back

Students with: open(), read(), close() step forward in order.

2.

FLASHCARD QUESTION

Front

Media Image

Back

The program should create a directory named "Hunt1", create a file called "treasures.dat" inside it, write a welcome message, and handle errors at every step.

3.

FLASHCARD QUESTION

Front

Media Image

Back

  1. 1. creat or open

  2. 2. fstat

  3. 3.write

  4. 4. close

  5. 5. perror for all of them

4.

FLASHCARD QUESTION

Front

LEVEL 2

A program needs to create a folder, create a file inside it, read some data, and close it.

Back

Expected calls: mkdir(), open(), read(), close()

5.

FLASHCARD QUESTION

Front

LEVEL 3
Inside Directory Dir1, create a file and write to it the text "Hello", read the message from the same file. If any step fails, an error should be printed.

Back

Expected calls: mkdir(), open() or creat(), write(), close(), open(), read(), close(), perror() for each.

6.

FLASHCARD QUESTION

Front

LEVEL 4

The program should check if "entry" is a regular file. In case it is, it reads from it 4 bytes. The read content is written at the end (be careful here) to a newly created file2.txt. In case is a directory, it must be renamed it. In case it is a symbolic link, it removes the link.

Back

  1. lstat() — Check metadata of entry

  2. S_ISREG — Evaluate st_mode to ensure it's a regular file

  3. open() — Open entry in read-only mode

  4. read() — Read 4 bytes from file1.txt

  5. close() — Close file1.txt

  6. creat() or open()— Open file2.txt in write or create mode

  7. lseek() - for writing at the end

  8. write() — Write the 4 bytes read into file2.txt

  9. close() — Close file2.txt

  10. S_ISDIR() + rename()

  11. S_ISLNK + unlink()


perror() — Should step in any time an error occurs

7.

FLASHCARD QUESTION

Front

LEVEL 5

Create a directory called Hunt1, add a treasure file and a log file, and create a symbolic link to the log file. At the end, remove the directory.

Back

  • mkdir() — Create the Hunt1 directory

  • open() — Open (or create) Hunt1/treasures.dat with O_CREAT

  • close() — Close the treasures file

  • open() — Open (or create) Hunt1/logged_hunt with O_CREAT

  • close() — Close the log file

  • symlink() — Create symbolic link from Hunt1/logged_hunt to logged_hunt-Hunt1 in the root directory

  • rmdir() -

  • 🔁 perror() — May appear after any step to report an error if one occurs (e.g., directory already exists)

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?