{ "q1": { "type": "blank", "question": "\n

On a typical Unix system, we are presented with two key storage\nabstractions. The first is the (1) ____, which is just a linear\narray of bytes that you can (2) ____ or (3) ____. Associated\nwith each of these is an (4) ____ number, which is its low-level\nname.

\n\n

The second abstraction is the (5) ____, which is a list of pairs\ncontaining the user-readable name of the data, and its assocated low-level\nidentifier.

\n" }, "q3": { "type": "blank", "question": "\n

Identify the key system call you should use to implement the\nfollowing Unix command-line utility:

\n\n

\n

    \n
  1. mkdir: ____
  2. \n
  3. rmdir: ____
  4. \n
  5. stat: ____
  6. \n
  7. chmod: ____
  8. \n
  9. kill: ____
  10. \n\n
  11. cd: ____
  12. \n
  13. mv: ____
  14. \n
  15. rm: ____
  16. \n
  17. ln: ____
  18. \n
  19. touch: ____
  20. \n
\n

\n" }, "q2": { "type": "order", "question": "\n

Identify the system call you should use to accomplish the\nfollowing tasks:

\n\n

\n

    \n
  1. Create a file.
  2. \n
  3. Load the contents of a file into memory.
  4. \n
  5. Store data in memory to a file.
  6. \n
  7. Move to a particular offset within a file.
  8. \n
  9. Flush data in memory to disk.
  10. \n
\n

\n", "responses": { "read": "read", "write": "write", "open": "open", "fsync": "fsync", "lseek": "lseek" } }, "q4": { "type": "blank", "question": "\n

Fill in the blanks for the following program: walk.c

\n\n

\n/* walk.c */\n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n\nint main(int argc, char *argv[]) {\n    /* Open directory handle */\n    DIR *d = ____(\".\");                                                     /* 1 */\n    if (!d) {\n        fprintf(stderr, \"%s\\n\", ____(errno));                               /* 2 */\n        return EXIT_FAILURE;\n    }\n\n    /* For each directory entry, check if it is a file, and print out the its\n     * name and file size */\n    for (struct dirent *e = ____(d); e; e = ____(d)) {                      /* 3 & 4 */\n        /* Skip current directory and parent directory */\n        if (strcmp(____, \".\") == 0 || strcmp(____, \"..\") == 0) {            /* 5 & 6 */\n            continue;\n        }\n\n        /* Skip non-regular files */\n        if (____ != DT_REG) {                                               /* 7 */\n            continue;\n        }\n\n        /* Get file meta-data */\n        struct stat s;\n        if (____(____, &s) < 0) {                                           /* 8 & 9 */\n            fprintf(stderr, \"%s\\n\", ____(errno));                           /* 10 */\n            continue;\n        }\n\n        /* Display file name and size */\n        printf(\"%s %lu\\n\", ____, ____);                                     /* 11 & 12 */\n    }\n\n    /* Close directory handle */\n    ____(d);                                                                /* 13 */\n    return EXIT_SUCCESS;\n}\n
\n\n

Note, that this program performs the equivalent of the following Python code:

\n\n
\nimport os\n\nfor name in os.listdir('.'):\n    if os.path.isfile(name):\n        print(name, os.path.getsize(name))\n
\n\n

Your program should display something like this:

\n\n
\nwalk.c 1161\nwalk 22896\nMakefile 565\nREADME.md 22\nwalk.py 136\n
\n" } }