00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00037 #include <inttypes.h>
00038 #include <errno.h>
00039 #include <str_error.h>
00040 #include <sys/types.h>
00041 #include <async.h>
00042 #include <devman.h>
00043 #include <str.h>
00044 #include <vfs/vfs.h>
00045 #include <sys/stat.h>
00046 #include <fcntl.h>
00047 #include "../tester.h"
00048
00049 #define DEVICE_CLASS "test3"
00050
00051 const char *test_devman2(void)
00052 {
00053 size_t idx = 1;
00054 int rc = EOK;
00055 const char *err_msg = NULL;
00056 char *path = NULL;
00057 while (rc == EOK) {
00058 rc = asprintf(&path, "/dev/class/%s\\%zu", DEVICE_CLASS, idx);
00059 if (rc < 0) {
00060 continue;
00061 }
00062 int fd = open(path, O_RDONLY);
00063 if (fd < 0) {
00064 TPRINTF("Failed opening `%s': %s.\n",
00065 path, str_error(fd));
00066 rc = fd;
00067 err_msg = "Failed opening file";
00068 continue;
00069 }
00070 int phone = fd_phone(fd);
00071 close(fd);
00072 if (phone < 0) {
00073 TPRINTF("Failed opening phone: %s.\n", str_error(phone));
00074 rc = phone;
00075 err_msg = "Failed opening file descriptor phone";
00076 continue;
00077 }
00078 async_hangup(phone);
00079 TPRINTF("Path `%s' okay.\n", path);
00080 free(path);
00081 idx++;
00082 rc = EOK;
00083 }
00084
00085 if (path != NULL) {
00086 free(path);
00087 }
00088
00089 return err_msg;
00090 }
00091