Script started on Wed Nov 19 17:26:54 2025 macbook:logs> cd ../programs/unix_ch13 macbook:unix_ch13> cd ../unix_ch12 macbook:unix_ch12> cd make_project_v2 macbook:make_project_v2> ls db db.h parts.h README.txt supps.h db.c Makefile parts.s supps.c macbook:make_project_v2> more parts.s .section __TEXT,__text,regular,pure_instructions .build_version macos, 15, 0 sdk_version 26, 1 .globl _array_init ; -- Begin function array_init .p2align 2 _array_init: ; @array_init .cfi_startproc ; %bb.0: sub sp, sp, #16 .cfi_def_cfa_offset 16 str x0, [sp, #8] str wzr, [sp, #4] b LBB0_1 LBB0_1: ; =>This Inner Loop Header: Depth=1 ldr w8, [sp, #4] subs w8, w8, #10 b.ge LBB0_4 b LBB0_2 LBB0_2: ; in Loop: Header=BB0_1 Depth=1 ldr x8, [sp, #8] str wzr, [x8] ldr x8, [sp, #8] add x8, x8, #4 str x8, [sp, #8] b LBB0_3 LBB0_3: ; in Loop: Header=BB0_1 Depth=1 ldr w8, [sp, #4] add w8, w8, #1 str w8, [sp, #4] b LBB0_1 LBB0_4: add sp, sp, #16 ret .cfi_endproc ; -- End function .globl _array_length ; -- Begin function array_length .p2align 2 _array_length: ; @array_length .cfi_startproc ; %bb.0: mov w0, #10 ; =0xa ret .cfi_endproc ; -- End function .globl _array_set ; -- Begin function array_set .p2align 2 _array_set: ; @array_set .cfi_startproc ; %bb.0: sub sp, sp, #16 .cfi_def_cfa_offset 16 str w0, [sp, #12] str w1, [sp, #8] ldr w8, [sp, #12] tbnz w8, #31, LBB2_3 b LBB2_1 LBB2_1: ldr w8, [sp, #12] subs w8, w8, #10 b.ge LBB2_3 b LBB2_2 LBB2_2: ldr w8, [sp, #8] ldrsw x10, [sp, #12] adrp x9, _a@GOTPAGE ldr x9, [x9, _a@GOTPAGEOFF] str w8, [x9, x10, lsl #2] b LBB2_3 LBB2_3: add sp, sp, #16 ret .cfi_endproc ; -- End function .comm _a,40,2 ; @a .subsections_via_symbols macbook:make_project_v2> cat Makefile db: db.o supps.o parts.o echo "make db" ; gcc db.o supps.o parts.o -o db db.o: db.c db.h supps.h parts.h echo "make db.o" ; gcc -c db.c supps.o: supps.c supps.h echo "make supps.o" ; gcc -c supps.c parts.o: parts.s parts.h echo "make parts.o" ; gcc -c parts.s macbook:make_project_v2> touch *.c macbook:make_project_v2> touch *.s macbook:make_project_v2> make echo "make db.o" ; gcc -c db.c make db.o echo "make supps.o" ; gcc -c supps.c make supps.o echo "make parts.o" ; gcc -c parts.s make parts.o echo "make db" ; gcc db.o supps.o parts.o -o db make db macbook:make_project_v2> ./db The array has 10 values Value 5 is prime. macbook:make_project_v2> cd ../ macbook:unix_ch12> cd ../ macbook:programs> cdn unix_ch13 zsh: command not found: cdn macbook:programs> grep WRON *.c macbook:programs> cat fileIOerror.c cat: fileIOerror.c: No such file or directory macbook:programs> cd unix_ch13 macbook:unix_ch13> cat fileIOerror.c #include #include #include int main () { int fd; /* Open a non-existent file to cause an error */ fd = open ("nonexist.txt", O_RDONLY); if (fd == -1) /* fd == -1 =, an error occurred */ { printf ("errno = %d\n", errno); perror ("main"); } /* Force a different error */ fd = open ("/", O_WRONLY); if (fd == -1) { printf ("errno = %d\n", errno); perror ("main"); } /* Execute a successful system call */ fd = open ("nonexist.txt", O_RDONLY | O_CREAT, 0644); /* Display after successful call */ printf ("errno = %d\n", errno); /* will display previous error num (21) */ perror ("main"); errno = 0; /* Manually reset error variable */ perror ("main"); return 0; } macbook:unix_ch13> ls nonexist.txt ls: nonexist.txt: No such file or directory macbook:unix_ch13> gcc fileIOerror.c macbook:unix_ch13> ./a.out errno = 2 main: No such file or directory errno = 21 main: Is a directory errno = 21 main: Is a directory main: Undefined error: 0 macbook:unix_ch13> ls nonexist.txt nonexist.txt macbook:unix_ch13> grep SEEK *.c reverse_unix_ch13_original.c: lseek (fd, lineStart[i], SEEK_SET); /* Find the line and read it */ reverse_unix_ch13.c: lseek (fd, lineStart[i], SEEK_SET); /* Find the line and read it */ sparse.c: lseek (fd, 60006, SEEK_SET); macbook:unix_ch13> vi seek_example.txt macbook:unix_ch13> mv seek_example.txt seek_example.c macbook:unix_ch13> cat seek_example.c // from char_count_per_line.c // Borrowed from the help file // Get the length of 'infile'. curpos = ftell(in); fseek(in, 0L, SEEK_END); length1 = ftell(in); fseek(in, curpos, SEEK_SET); fclose(in); if (DEBUG) printf("Size of file is %ld\n",length1); macbook:unix_ch13> cat processDirectory.c // This function is from Glass and Ables' Unix book // See monitor.c (starting on p 453) #include /* For printf, fprintf */ #include // exit() #include /* For strcmp */ #include /* For isdigit */ #include /* For O_RDONLY */ #include /* For getdents */ #include /* For IS macros */ #include /* For modet */ #include /* For localtime, asctime */ void processDirectory (char* dirName) { /* Process all files in the named directory */ DIR *dp; struct dirent *dep; //char fileName [MAX_FILENAME]; dp = opendir (dirName); /* Open for reading */ if (dp == NULL) { perror("monitor: "); exit(1); } while ((dep = readdir(dp))) /* Read all dir entries */ { if (strcmp (dep->d_name, ".") != 0&& strcmp (dep->d_name, "..") != 0) /* Skip . .. */ { printf ("%s/%s \n", dirName, dep->d_name); // was sprintf //monitorFile (fileName); /* Call recursively */ } } closedir (dp); /* Close directory */ } int main (int argc, char *argv[]) { if (argc < 2) { printf("You need to pass a dir name\n"); return -1; } processDirectory(argv[1]); return 0; } macbook:unix_ch13> gcc processDirectory.c macbook:unix_ch13> ./a.out . ./myfork.c ./monitor_original.c ./pgrp2.c ./myexec.c ./myfork2.c ./monitor.c ./pipe_fork_signal_wait.c ./unnamed_pipes_figure.txt ./process2.c ./processDirectory.c ./exec_man_page.html ./nonexist.txt ./seek_example.c ./mychdir.c ./sparse.c ./pgrp1.c ./sparse.txt ./myexit.c ./lstat_example.c ./mydup.c ./fork_example2.c ./zombie.c ./talk.c ./myfork4.c ./reverse_ch13_KandR.c ./a.out ./reverse_unix_ch13.c ./pipe_example.c ./mydup_w_comments.c ./pipe_example_3.c ./test.txt ./pipe_example_v2.c ./fork_example.c ./orphan.c ./processDirectory_v2.c ./myfork3.c ./wait.c ./reverse_unix_ch13_original.c ./mywait.c ./fileIOerror.c ./talk ./normal.txt macbook:unix_ch13> macbook:unix_ch13> echo "Whats is your favorite language?" Whats is your favorite language? macbook:unix_ch13> exit Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. Deleting expired sessions...none found. Script done on Wed Nov 19 18:44:31 2025