From 807252305f8705a7470228a3f4e180c26798e89c Mon Sep 17 00:00:00 2001 From: Stathis Kamperis Date: Wed, 20 Feb 2008 21:30:14 +0200 Subject: [PATCH] Separate netbsd-specific from unix-specific projects --- ipc/fork.c | 31 ---------- ipc/fork_execlp.c | 37 ------------ ipc/fork_mult.c | 37 ------------ ipc/mmap.c | 74 ----------------------- ipc/popen_ls.c | 57 ----------------- {cdev => netbsd/cdev}/copyfiles.sh | 0 {cdev => netbsd/cdev}/mydev.c | 0 {cdev => netbsd/cdev}/mydev.h | 4 +- {cdev => netbsd/cdev}/test.c | 4 +- {fileops => netbsd/fileops}/disklabel.c | 0 {fileops => netbsd/fileops}/hexdump.c | 0 {fileops => netbsd/fileops}/listdir.c | 0 {fileops => netbsd/fileops}/listdir_recursive.c | 0 {fileops => netbsd/fileops}/readwd.c | 0 {genstructs => netbsd/genstructs}/htable/htable.c | 0 {genstructs => netbsd/genstructs}/htable/htable.h | 0 {genstructs => netbsd/genstructs}/htable/test1.c | 0 {genstructs => netbsd/genstructs}/slinkedlist.c | 0 {genstructs => netbsd/genstructs}/tailq.c | 0 {kqueue => netbsd/kqueue}/kqclient.c | 0 {kqueue => netbsd/kqueue}/kqdir.c | 0 {kqueue => netbsd/kqueue}/kqtimer.c | 0 {proplib => netbsd/proplib}/prop_dict.c | 0 {proplib => netbsd/proplib}/prop_parse_du.c | 0 {proplib => netbsd/proplib}/prop_read_array_.c | 0 {proplib => netbsd/proplib}/prop_write_array.c | 0 {homework => unix/homework}/bitmap.c | 0 {homework => unix/homework}/charfreq.c | 0 {homework => unix/homework}/tree.c | 0 {malloc => unix/malloc}/mpool.c | 0 {malloc => unix/malloc}/mpool.h | 0 {malloc => unix/malloc}/mstat.c | 0 {malloc => unix/malloc}/mstat.h | 0 {malloc => unix/malloc}/test1.c | 0 {malloc => unix/malloc}/test2.c | 0 {malloc => unix/malloc}/test3.c | 0 {malloc => unix/malloc}/test4.c | 0 {misc => unix/misc}/fsm/Makefile | 0 {misc => unix/misc}/fsm/TODO | 0 {misc => unix/misc}/fsm/fsm.c | 0 {misc => unix/misc}/fsm/fsm.h | 0 {misc => unix/misc}/fsm/states.c | 0 {misc => unix/misc}/fsm/states.h | 0 {misc => unix/misc}/fsm/test_rmcom.c | 0 {misc => unix/misc}/fsm/test_stress.c | 0 {misc => unix/misc}/fsm/test_thread.c | 0 {misc => unix/misc}/fsm/types.h | 0 {pthreads => unix/pthreads}/matrixmul/mat1.dat | 0 {pthreads => unix/pthreads}/matrixmul/mat2.dat | 0 {pthreads => unix/pthreads}/matrixmul/matrixmul.c | 0 {pthreads => unix/pthreads}/pthread_create.c | 0 {pthreads => unix/pthreads}/pthread_join.c | 0 {pthreads => unix/pthreads}/pthread_mutex.c | 0 {pthreads => unix/pthreads}/pthread_semaphore.c | 0 {pthreads => unix/pthreads}/sleepbarber.c | 0 {termios => unix/termios}/echo_off.c | 0 56 files changed, 4 insertions(+), 240 deletions(-) delete mode 100644 ipc/fork.c delete mode 100644 ipc/fork_execlp.c delete mode 100644 ipc/fork_mult.c delete mode 100644 ipc/mmap.c delete mode 100644 ipc/popen_ls.c rename {cdev => netbsd/cdev}/copyfiles.sh (100%) rename {cdev => netbsd/cdev}/mydev.c (100%) rename {cdev => netbsd/cdev}/mydev.h (74%) rename {cdev => netbsd/cdev}/test.c (92%) rename {fileops => netbsd/fileops}/disklabel.c (100%) rename {fileops => netbsd/fileops}/hexdump.c (100%) rename {fileops => netbsd/fileops}/listdir.c (100%) rename {fileops => netbsd/fileops}/listdir_recursive.c (100%) rename {fileops => netbsd/fileops}/readwd.c (100%) rename {genstructs => netbsd/genstructs}/htable/htable.c (100%) rename {genstructs => netbsd/genstructs}/htable/htable.h (100%) rename {genstructs => netbsd/genstructs}/htable/test1.c (100%) rename {genstructs => netbsd/genstructs}/slinkedlist.c (100%) rename {genstructs => netbsd/genstructs}/tailq.c (100%) rename {kqueue => netbsd/kqueue}/kqclient.c (100%) rename {kqueue => netbsd/kqueue}/kqdir.c (100%) rename {kqueue => netbsd/kqueue}/kqtimer.c (100%) rename {proplib => netbsd/proplib}/prop_dict.c (100%) rename {proplib => netbsd/proplib}/prop_parse_du.c (100%) rename {proplib => netbsd/proplib}/prop_read_array_.c (100%) rename {proplib => netbsd/proplib}/prop_write_array.c (100%) rename {homework => unix/homework}/bitmap.c (100%) rename {homework => unix/homework}/charfreq.c (100%) rename {homework => unix/homework}/tree.c (100%) rename {malloc => unix/malloc}/mpool.c (100%) rename {malloc => unix/malloc}/mpool.h (100%) rename {malloc => unix/malloc}/mstat.c (100%) rename {malloc => unix/malloc}/mstat.h (100%) rename {malloc => unix/malloc}/test1.c (100%) rename {malloc => unix/malloc}/test2.c (100%) rename {malloc => unix/malloc}/test3.c (100%) rename {malloc => unix/malloc}/test4.c (100%) rename {misc => unix/misc}/fsm/Makefile (100%) rename {misc => unix/misc}/fsm/TODO (100%) rename {misc => unix/misc}/fsm/fsm.c (100%) rename {misc => unix/misc}/fsm/fsm.h (100%) rename {misc => unix/misc}/fsm/states.c (100%) rename {misc => unix/misc}/fsm/states.h (100%) rename {misc => unix/misc}/fsm/test_rmcom.c (100%) rename {misc => unix/misc}/fsm/test_stress.c (100%) rename {misc => unix/misc}/fsm/test_thread.c (100%) rename {misc => unix/misc}/fsm/types.h (100%) rename {pthreads => unix/pthreads}/matrixmul/mat1.dat (100%) rename {pthreads => unix/pthreads}/matrixmul/mat2.dat (100%) rename {pthreads => unix/pthreads}/matrixmul/matrixmul.c (100%) rename {pthreads => unix/pthreads}/pthread_create.c (100%) rename {pthreads => unix/pthreads}/pthread_join.c (100%) rename {pthreads => unix/pthreads}/pthread_mutex.c (100%) rename {pthreads => unix/pthreads}/pthread_semaphore.c (100%) rename {pthreads => unix/pthreads}/sleepbarber.c (100%) rename {termios => unix/termios}/echo_off.c (100%) diff --git a/ipc/fork.c b/ipc/fork.c deleted file mode 100644 index 7e020a2..0000000 --- a/ipc/fork.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Compile with: - * gcc fork.c -o fork -Wall -W -Wextra -ansi -pedantic - */ - -#include -#include -#include - -int main(void) -{ - pid_t pid; - - if ((pid = fork()) < 0) { /* fork error */ - perror("fork()"); - exit(EXIT_FAILURE); - } - - else if (pid > 0) /* parent process */ - printf("Parent's pid: %d\n", getpid()); - - else /* child process (pid = 0) */ - printf("Child's pid: %d\n", getpid()); - - /* - * Whatever goes here, will be executed from the - * parent AND the child process as well. - */ - - return EXIT_SUCCESS; -} diff --git a/ipc/fork_execlp.c b/ipc/fork_execlp.c deleted file mode 100644 index 2bffc3a..0000000 --- a/ipc/fork_execlp.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Compile with: - * gcc fork_execlp.c -o fork_execlp -Wall -W -Wextra -ansi -pedantic - */ - -#include -#include -#include -#include - -int main(void) -{ - pid_t pid; - int retval; - - if ((pid = fork()) < 0) { /* fork error */ - perror("fork()"); - exit(EXIT_FAILURE); - } - - else if (pid > 0) /* parent process */ - wait(&retval); - - else { /* child process (pid = 0) */ - if (execlp("date", "date", (char *)0) < 0) { - perror("execlp()"); - exit(EXIT_FAILURE); - } - } - - /* - * Whatever goes here, will be executed from the - * parent AND the child process as well - */ - - return EXIT_SUCCESS; -} diff --git a/ipc/fork_mult.c b/ipc/fork_mult.c deleted file mode 100644 index ea0385e..0000000 --- a/ipc/fork_mult.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Compile with: - * gcc fork_mult.c -o fork_mult -Wall -W -Wextra -ansi -pedantic - */ - -#include -#include -#include -#include - -#define NUM_CHILDS 5 - -int main(void) -{ - pid_t pid[NUM_CHILDS]; - int i, retval; - - for (i = 0; i < NUM_CHILDS; i++) { - if ((pid[i] = fork()) < 0) { /* fork error */ - perror("fork()"); - exit(EXIT_FAILURE); - } - - else if (pid[i] > 0) { /* parent process */ - wait(&retval); - } - - else { /* child process (pid = 0) */ - printf("Child[%d] = %d\n", i, getpid()); - - /* Break, or else every child will spawn its own children */ - break; - } - } - - return EXIT_SUCCESS; -} diff --git a/ipc/mmap.c b/ipc/mmap.c deleted file mode 100644 index 6f2f2c2..0000000 --- a/ipc/mmap.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Compile with: - * gcc mmap.c -o mmap -Wall -W -Wextra -ansi -pedantic - */ - -#include -#include -#include -#include -#include -#include - -/* Function prototypes */ -void diep(const char *s); - -int main(int argc, char *argv[]) -{ - const char *message = "this shall be written to file\n"; - char *map; - int fd; - - /* Check argument count */ - if (argc != 2) { - fprintf(stderr, "Usage: %s\n", argv[0]); - exit(EXIT_FAILURE); - } - - /* Open file */ - if ((fd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600)) == -1) - diep("open()"); - - /* Stretch the file size to the size of the (mmapped) array of chars */ - if (lseek(fd, strlen(message) - 1, SEEK_SET) == -1) { - close(fd); - diep("lseek()"); - } - - /* - * Something needs to be written at the end of the file to - * have the file actually have the new size. - */ - if (write(fd, "", 1) != 1) { - close(fd); - diep("write()"); - } - - /* mmap() the file */ - if ((map = (char *)mmap(0, strlen(message), - PROT_WRITE, - MAP_SHARED, fd, 0)) == MAP_FAILED) { - close(fd); - diep("mmap()"); - } - - /* Copy message to mmapped() memory */ - memcpy(map, message, strlen(message)); - - /* Free the mmaped() memory */ - if (munmap(map, strlen(message)) == -1) { - close(fd); - exit(EXIT_FAILURE); - } - - /* Close file */ - close(fd); - - return EXIT_SUCCESS; -} - -void diep(const char *s) -{ - perror(s); - exit(EXIT_FAILURE); -} diff --git a/ipc/popen_ls.c b/ipc/popen_ls.c deleted file mode 100644 index 61d2e28..0000000 --- a/ipc/popen_ls.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include /* for waitpid() macros */ - -#define MAX_STR 100 - -int main(void) -{ - char str[MAX_STR]; - int ret; - FILE *fp; - - /* Initiate pipe stream to ls(1) */ - fp = popen("ls", "r"); - if (fp == NULL) { - perror("popen()"); - exit(EXIT_FAILURE); - } - - /* Read from stream */ - while (fgets(str, MAX_STR, fp) != NULL) - printf("%s", str); - - /* Close pipe stream */ - ret = pclose(fp); - if (ret == -1) { - perror("pclose()"); - exit(EXIT_FAILURE); - } - else { - /* - * Use macros described under wait() to inspect the return value - * of pclose() in order to determine success/failure of command - * executed by popen(). - */ - - if (WIFEXITED(ret)) { - printf("Child exited, ret = %d\n", WEXITSTATUS(ret)); - } else if (WIFSIGNALED(ret)) { - printf("Child killed, signal %d\n", WTERMSIG(ret)); - } else if (WIFSTOPPED(ret)) { - printf("Child stopped, signal %d\n", WSTOPSIG(ret)); - } - /* Not all implementations support this */ -#ifdef WIFCONTINUED - else if (WIFCONTINUED(ret)) { - printf("Child continued\n"); - } -#endif - /* Non standard case -- may never happen */ - else { - printf("Unexpected return value, ret = 0x%x\n", ret); - } - } - - return EXIT_SUCCESS; -} diff --git a/cdev/copyfiles.sh b/netbsd/cdev/copyfiles.sh similarity index 100% rename from cdev/copyfiles.sh rename to netbsd/cdev/copyfiles.sh diff --git a/cdev/mydev.c b/netbsd/cdev/mydev.c similarity index 100% rename from cdev/mydev.c rename to netbsd/cdev/mydev.c diff --git a/cdev/mydev.h b/netbsd/cdev/mydev.h similarity index 74% rename from cdev/mydev.h rename to netbsd/cdev/mydev.h index cbffd0b..5c4338e 100644 --- a/cdev/mydev.h +++ b/netbsd/cdev/mydev.h @@ -15,8 +15,8 @@ struct mydev_params char string[80]; }; -#define MYDEVTEST _IOW('S', 0x1, struct mydev_params) -#define MYDEVSETPROPS _IOW('S', 0x2, struct plistref) +#define MYDEVTEST _IOW('M', 0x1, struct mydev_params) +#define MYDEVSETPROPS _IOW('M', 0x2, struct plistref) #ifdef _KERNEL diff --git a/cdev/test.c b/netbsd/cdev/test.c similarity index 92% rename from cdev/test.c rename to netbsd/cdev/test.c index 0a42cea..a7cc5b9 100644 --- a/cdev/test.c +++ b/netbsd/cdev/test.c @@ -35,14 +35,14 @@ int main() err("prop_dictionary_create()"); } - ps = prop_string_create_cstring("key"); + ps = prop_string_create_cstring("value"); if (ps == NULL) { close(devfd); prop_object_release(pd); err("prop_string_create_cstring()"); } - if (prop_dictionary_set(pd, "value", ps) == false) { + if (prop_dictionary_set(pd, "key", ps) == false) { close(devfd); prop_object_release(ps); prop_object_release(pd); diff --git a/fileops/disklabel.c b/netbsd/fileops/disklabel.c similarity index 100% rename from fileops/disklabel.c rename to netbsd/fileops/disklabel.c diff --git a/fileops/hexdump.c b/netbsd/fileops/hexdump.c similarity index 100% rename from fileops/hexdump.c rename to netbsd/fileops/hexdump.c diff --git a/fileops/listdir.c b/netbsd/fileops/listdir.c similarity index 100% rename from fileops/listdir.c rename to netbsd/fileops/listdir.c diff --git a/fileops/listdir_recursive.c b/netbsd/fileops/listdir_recursive.c similarity index 100% rename from fileops/listdir_recursive.c rename to netbsd/fileops/listdir_recursive.c diff --git a/fileops/readwd.c b/netbsd/fileops/readwd.c similarity index 100% rename from fileops/readwd.c rename to netbsd/fileops/readwd.c diff --git a/genstructs/htable/htable.c b/netbsd/genstructs/htable/htable.c similarity index 100% rename from genstructs/htable/htable.c rename to netbsd/genstructs/htable/htable.c diff --git a/genstructs/htable/htable.h b/netbsd/genstructs/htable/htable.h similarity index 100% rename from genstructs/htable/htable.h rename to netbsd/genstructs/htable/htable.h diff --git a/genstructs/htable/test1.c b/netbsd/genstructs/htable/test1.c similarity index 100% rename from genstructs/htable/test1.c rename to netbsd/genstructs/htable/test1.c diff --git a/genstructs/slinkedlist.c b/netbsd/genstructs/slinkedlist.c similarity index 100% rename from genstructs/slinkedlist.c rename to netbsd/genstructs/slinkedlist.c diff --git a/genstructs/tailq.c b/netbsd/genstructs/tailq.c similarity index 100% rename from genstructs/tailq.c rename to netbsd/genstructs/tailq.c diff --git a/kqueue/kqclient.c b/netbsd/kqueue/kqclient.c similarity index 100% rename from kqueue/kqclient.c rename to netbsd/kqueue/kqclient.c diff --git a/kqueue/kqdir.c b/netbsd/kqueue/kqdir.c similarity index 100% rename from kqueue/kqdir.c rename to netbsd/kqueue/kqdir.c diff --git a/kqueue/kqtimer.c b/netbsd/kqueue/kqtimer.c similarity index 100% rename from kqueue/kqtimer.c rename to netbsd/kqueue/kqtimer.c diff --git a/proplib/prop_dict.c b/netbsd/proplib/prop_dict.c similarity index 100% rename from proplib/prop_dict.c rename to netbsd/proplib/prop_dict.c diff --git a/proplib/prop_parse_du.c b/netbsd/proplib/prop_parse_du.c similarity index 100% rename from proplib/prop_parse_du.c rename to netbsd/proplib/prop_parse_du.c diff --git a/proplib/prop_read_array_.c b/netbsd/proplib/prop_read_array_.c similarity index 100% rename from proplib/prop_read_array_.c rename to netbsd/proplib/prop_read_array_.c diff --git a/proplib/prop_write_array.c b/netbsd/proplib/prop_write_array.c similarity index 100% rename from proplib/prop_write_array.c rename to netbsd/proplib/prop_write_array.c diff --git a/homework/bitmap.c b/unix/homework/bitmap.c similarity index 100% rename from homework/bitmap.c rename to unix/homework/bitmap.c diff --git a/homework/charfreq.c b/unix/homework/charfreq.c similarity index 100% rename from homework/charfreq.c rename to unix/homework/charfreq.c diff --git a/homework/tree.c b/unix/homework/tree.c similarity index 100% rename from homework/tree.c rename to unix/homework/tree.c diff --git a/malloc/mpool.c b/unix/malloc/mpool.c similarity index 100% rename from malloc/mpool.c rename to unix/malloc/mpool.c diff --git a/malloc/mpool.h b/unix/malloc/mpool.h similarity index 100% rename from malloc/mpool.h rename to unix/malloc/mpool.h diff --git a/malloc/mstat.c b/unix/malloc/mstat.c similarity index 100% rename from malloc/mstat.c rename to unix/malloc/mstat.c diff --git a/malloc/mstat.h b/unix/malloc/mstat.h similarity index 100% rename from malloc/mstat.h rename to unix/malloc/mstat.h diff --git a/malloc/test1.c b/unix/malloc/test1.c similarity index 100% rename from malloc/test1.c rename to unix/malloc/test1.c diff --git a/malloc/test2.c b/unix/malloc/test2.c similarity index 100% rename from malloc/test2.c rename to unix/malloc/test2.c diff --git a/malloc/test3.c b/unix/malloc/test3.c similarity index 100% rename from malloc/test3.c rename to unix/malloc/test3.c diff --git a/malloc/test4.c b/unix/malloc/test4.c similarity index 100% rename from malloc/test4.c rename to unix/malloc/test4.c diff --git a/misc/fsm/Makefile b/unix/misc/fsm/Makefile similarity index 100% rename from misc/fsm/Makefile rename to unix/misc/fsm/Makefile diff --git a/misc/fsm/TODO b/unix/misc/fsm/TODO similarity index 100% rename from misc/fsm/TODO rename to unix/misc/fsm/TODO diff --git a/misc/fsm/fsm.c b/unix/misc/fsm/fsm.c similarity index 100% rename from misc/fsm/fsm.c rename to unix/misc/fsm/fsm.c diff --git a/misc/fsm/fsm.h b/unix/misc/fsm/fsm.h similarity index 100% rename from misc/fsm/fsm.h rename to unix/misc/fsm/fsm.h diff --git a/misc/fsm/states.c b/unix/misc/fsm/states.c similarity index 100% rename from misc/fsm/states.c rename to unix/misc/fsm/states.c diff --git a/misc/fsm/states.h b/unix/misc/fsm/states.h similarity index 100% rename from misc/fsm/states.h rename to unix/misc/fsm/states.h diff --git a/misc/fsm/test_rmcom.c b/unix/misc/fsm/test_rmcom.c similarity index 100% rename from misc/fsm/test_rmcom.c rename to unix/misc/fsm/test_rmcom.c diff --git a/misc/fsm/test_stress.c b/unix/misc/fsm/test_stress.c similarity index 100% rename from misc/fsm/test_stress.c rename to unix/misc/fsm/test_stress.c diff --git a/misc/fsm/test_thread.c b/unix/misc/fsm/test_thread.c similarity index 100% rename from misc/fsm/test_thread.c rename to unix/misc/fsm/test_thread.c diff --git a/misc/fsm/types.h b/unix/misc/fsm/types.h similarity index 100% rename from misc/fsm/types.h rename to unix/misc/fsm/types.h diff --git a/pthreads/matrixmul/mat1.dat b/unix/pthreads/matrixmul/mat1.dat similarity index 100% rename from pthreads/matrixmul/mat1.dat rename to unix/pthreads/matrixmul/mat1.dat diff --git a/pthreads/matrixmul/mat2.dat b/unix/pthreads/matrixmul/mat2.dat similarity index 100% rename from pthreads/matrixmul/mat2.dat rename to unix/pthreads/matrixmul/mat2.dat diff --git a/pthreads/matrixmul/matrixmul.c b/unix/pthreads/matrixmul/matrixmul.c similarity index 100% rename from pthreads/matrixmul/matrixmul.c rename to unix/pthreads/matrixmul/matrixmul.c diff --git a/pthreads/pthread_create.c b/unix/pthreads/pthread_create.c similarity index 100% rename from pthreads/pthread_create.c rename to unix/pthreads/pthread_create.c diff --git a/pthreads/pthread_join.c b/unix/pthreads/pthread_join.c similarity index 100% rename from pthreads/pthread_join.c rename to unix/pthreads/pthread_join.c diff --git a/pthreads/pthread_mutex.c b/unix/pthreads/pthread_mutex.c similarity index 100% rename from pthreads/pthread_mutex.c rename to unix/pthreads/pthread_mutex.c diff --git a/pthreads/pthread_semaphore.c b/unix/pthreads/pthread_semaphore.c similarity index 100% rename from pthreads/pthread_semaphore.c rename to unix/pthreads/pthread_semaphore.c diff --git a/pthreads/sleepbarber.c b/unix/pthreads/sleepbarber.c similarity index 100% rename from pthreads/sleepbarber.c rename to unix/pthreads/sleepbarber.c diff --git a/termios/echo_off.c b/unix/termios/echo_off.c similarity index 100% rename from termios/echo_off.c rename to unix/termios/echo_off.c -- 2.11.4.GIT