/* Test mknod's capability of creating device nodes with major and minor in (12, 20) format Copyright (C) 2008 Texas Instruments, Inc. Author : Mansoor Ahamed , 2008. Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #include #include #include #include #include #include #include #include #include #include /* Name of the node. */ char tmpname[] = "tst-mknod-1"; /* #define TST_MKNOD_STANDALONE 1 */ static void do_cleanup (void) { remove (tmpname); } #ifndef TST_MKNOD_STANDALONE static int do_test (void) #else int main(void) #endif { int maj = 442, min = 2048; struct stat64 stats; mode_t mode = 0666 | S_IFCHR; /* Create a character device with major=442 and minor=2048 */ if (mknod (tmpname, mode, makedev(maj, min)) < 0) { perror ("mknod"); goto mknod_cleanup; } /* even stat() should work, but kernel should support */ if (stat64(tmpname, &stats) != 0) { perror ("stat"); goto mknod_cleanup; } if (stats.st_rdev != makedev(maj, min)) { fprintf(stderr, "tst-mknod[FAIL]: failed creating device nodes "); fprintf(stderr, "with major and minor in (12, 20) format\n"); } else { fprintf(stderr, "tst-mknod[PASS]: could create device nodes "); fprintf(stderr, "with major and minor in (12, 20) format\n"); } mknod_cleanup: do_cleanup(); return 0; } #ifndef TST_MKNOD_STANDALONE #define CLEANUP_HANDLER do_cleanup () #define TEST_FUNCTION do_test () /* Include the test skeleton. */ #include "../test-skeleton.c" #endif