int duet_deregister(int duet_fd, int tid) { int ret = 0; struct duet_ioctl_cmd_args args; if (duet_fd == -1) { fprintf(stderr, "duet: failed to open duet device\n"); return -1; } memset(&args, 0, sizeof(args)); args.cmd_flags = DUET_DEREGISTER; args.tid = tid; ret = ioctl(duet_fd, DUET_IOC_CMD, &args); if (ret < 0) perror("duet: tasks deregister ioctl error"); if (args.ret) duet_dbg(stdout, "Error deregistering task (ID %d).\n", args.tid); else duet_dbg(stdout, "Successfully deregistered task (ID %d).\n", args.tid); return (ret < 0) ? ret : args.ret; }
int duet_register(const char *name, __u32 regmask, const char *path) { int duet_fd, ret = 0; struct duet_ioctl_init_args args; args.size = sizeof(args); memcpy(args.name, name, NAME_MAX); args.regmask = regmask; memcpy(args.path, path, PATH_MAX); /* Open the duet device */ duet_fd = open_duet_dev(); if (duet_fd == -1) { fprintf(stderr, "Error: failed to open duet device\n"); return -1; } ret = ioctl(duet_fd, DUET_IOC_INIT, &args); if (ret < 0) perror("duet_register: ioctl failed"); if (!ret) duet_dbg(stdout, "Error registering task %s.\n", name); else duet_dbg(stdout, "Successfully registered task %s.\n", name); close_duet_dev(duet_fd); return ret; }
int duet_register(int duet_fd, const char *path, __u32 regmask, __u32 bitrange, const char *name, int *tid) { int ret = 0; struct duet_ioctl_cmd_args args; if (duet_fd == -1) { fprintf(stderr, "duet: failed to open duet device\n"); return -1; } memset(&args, 0, sizeof(args)); args.cmd_flags = DUET_REGISTER; memcpy(args.name, name, DUET_MAX_NAME); args.bitrange = bitrange; args.regmask = regmask; memcpy(args.path, path, DUET_MAX_PATH); ret = ioctl(duet_fd, DUET_IOC_CMD, &args); if (ret < 0) perror("duet: tasks register ioctl error"); *tid = args.tid; if (args.ret) duet_dbg(stdout, "Error registering task (ID %d).\n", args.tid); else duet_dbg(stdout, "Successfully registered task (ID %d).\n", args.tid); return (ret < 0) ? ret : args.ret; }
int duet_unset_done(int duet_fd, int tid, __u64 idx, __u32 count) { int ret = 0; struct duet_ioctl_cmd_args args; if (duet_fd == -1) { fprintf(stderr, "duet: failed to open duet device\n"); return -1; } memset(&args, 0, sizeof(args)); args.cmd_flags = DUET_UNSET_DONE; args.tid = tid; args.itmidx = idx; args.itmnum = count; ret = ioctl(duet_fd, DUET_IOC_CMD, &args); if (ret < 0) perror("duet: unmark ioctl error"); duet_dbg("Removed blocks [%llu, %llu] to task #%d (ret = %u).\n", args.itmidx, args.itmidx + args.itmnum, args.tid, args.ret); return (ret < 0) ? ret : args.ret; }
int duet_check_done(int duet_fd, int tid, __u64 idx, __u32 count) { int ret = 0; struct duet_ioctl_cmd_args args; if (duet_fd == -1) { fprintf(stderr, "duet: failed to open duet device\n"); return -1; } memset(&args, 0, sizeof(args)); args.cmd_flags = DUET_CHECK_DONE; args.tid = tid; args.itmidx = idx; args.itmnum = count; ret = ioctl(duet_fd, DUET_IOC_CMD, &args); if (ret < 0) perror("duet: check ioctl error"); duet_dbg("Blocks [%llu, %llu] in task #%d were %sset.\n", args.itmidx, args.itmidx + args.itmnum, args.tid, args.ret ? "" : "not "); return (ret < 0) ? ret : args.ret; }
int duet_set_done(struct duet_uuid uuid) { int duet_fd, ret = 0; struct duet_ioctl_bmap_args args; args.size = sizeof(args); args.flags = DUET_BMAP_SET; args.uuid = uuid; /* Open the duet device */ duet_fd = open_duet_dev(); if (duet_fd == -1) { fprintf(stderr, "Error: failed to open duet device\n"); return -1; } ret = ioctl(duet_fd, DUET_IOC_BMAP, &args); if (ret < 0) perror("duet_set_done: ioctl failed"); if (!ret) duet_dbg("Added (ino%lu, gen%u) to task %d\n", args.uuid.ino, args.uuid.gen, args.uuid.tid); close_duet_dev(duet_fd); return ret; }
/* Caller needs to free returned path */ char *duet_get_path(struct duet_uuid uuid) { int duet_fd, ret; char *path; struct duet_ioctl_gpath_args args; path = calloc(PATH_MAX, sizeof(char)); if (!path) return path; args.size = sizeof(args); args.uuid = uuid; args.path[0] = '\0'; /* Open the duet device */ duet_fd = open_duet_dev(); if (duet_fd == -1) { fprintf(stderr, "Error: failed to open duet device\n"); free(path); return NULL; } ret = ioctl(duet_fd, DUET_IOC_GPATH, &args); if (ret < 0) perror("duet_get_path: ioctl failed"); if (!ret) { duet_dbg("(ino%lu, gen%u) was matched to path %s\n", args.uuid.ino, args.uuid.gen, args.path); memcpy(path, args.path, PATH_MAX); } close_duet_dev(duet_fd); return path; }
int duet_check_done(struct duet_uuid uuid) { int duet_fd, ret = 0; struct duet_ioctl_bmap_args args; args.size = sizeof(args); args.flags = DUET_BMAP_CHECK; args.uuid = uuid; /* Open the duet device */ duet_fd = open_duet_dev(); if (duet_fd == -1) { fprintf(stderr, "Error: failed to open duet device\n"); return -1; } ret = ioctl(duet_fd, DUET_IOC_BMAP, &args); if (ret < 0) perror("duet_check_done: ioctl failed"); if (ret >= 0) duet_dbg("(ino%lu, gen%u) in task %d is %sset (ret%d)\n", args.uuid.ino, args.uuid.gen, args.uuid.tid, (ret == 1) ? "" : "not ", ret); close_duet_dev(duet_fd); return ret; }
int duet_register(const char *name, __u32 regmask, const char *path) { int ret = 0; /* Call syscall x86_64 #330: duet_init */ ret = syscall(330, name, regmask, path); if (ret < 0) perror("duet_register: syscall failed"); if (!ret) duet_dbg(stdout, "Error registering task %s.\n", name); else duet_dbg(stdout, "Successfully registered task %s.\n", name); return ret; }
int duet_reset_done(struct duet_uuid uuid) { int ret = 0; struct duet_uuid_arg arg; arg.size = sizeof(arg); arg.uuid = uuid; /* Call syscall x86_64 #331: duet_bmap */ ret = syscall(331, DUET_BMAP_RESET, &arg); if (ret < 0) perror("duet_reset_done: syscall failed"); if (!ret) duet_dbg("Removed (ino%lu, gen%u) to task %d\n", arg.uuid.ino, arg.uuid.gen, arg.uuid.tid); return ret; }
int duet_check_done(struct duet_uuid uuid) { int ret = 0; struct duet_uuid_arg arg; arg.size = sizeof(arg); arg.uuid = uuid; /* Call syscall x86_64 #331: duet_bmap */ ret = syscall(331, DUET_BMAP_CHECK, &arg); if (ret < 0) perror("duet_check_done: syscall failed"); if (ret >= 0) duet_dbg("(ino%lu, gen%u) in task %d is %sset (ret%d)\n", arg.uuid.ino, arg.uuid.gen, arg.uuid.tid, (ret == 1) ? "" : "not ", ret); return ret; }
/* Caller needs to free returned path */ char *duet_get_path(struct duet_uuid uuid) { int ret; char *path; struct duet_uuid_arg arg; path = calloc(PATH_MAX, sizeof(char)); if (!path) return path; arg.size = sizeof(arg); arg.uuid = uuid; /* Call syscall x86_64 #332: duet_get_path */ ret = syscall(332, &arg, path, PATH_MAX); if (ret < 0) perror("duet_get_path: syscall failed"); if (!ret) duet_dbg("(ino%lu, gen%u) was matched to path %s\n", uuid.ino, uuid.gen, path); return path; }