+static void handle_open(struct pfiled *pfiled, struct io *io)
+{
+ struct xseg_request *req = io->req;
+ char *buf = malloc(MAX_FILENAME_SIZE + strlen("_lock"));
+ char *pathname = malloc(MAX_PATH_SIZE + MAX_FILENAME_SIZE + strlen("_lock"));
+ int fd;
+ char *target = xseg_get_target(pfiled->xseg, req);
+
+ if (!buf || !pathname) {
+ fail(pfiled, io);
+ return;
+ }
+
+ strncpy(buf, target, req->targetlen);
+ strncpy(buf+req->targetlen, "_lock", strlen("_lock"));
+
+ if (create_path(pathname, pfiled->vpath, buf, req->targetlen + strlen("_lock"), 1) < 0) {
+ goto out_fail;
+ }
+
+ fd = open(pathname, O_CREAT | O_EXCL, S_IRWXU | S_IRUSR);
+ if (fd < 0)
+ goto out_fail;
+
+ close(fd);
+ free(buf);
+ free(pathname);
+ complete(pfiled, io);
+ return;
+
+out_fail:
+ free(buf);
+ free(pathname);
+ fail(pfiled, io);
+ return;
+}
+
+static void handle_close(struct pfiled *pfiled, struct io *io)
+{
+ struct xseg_request *req = io->req;
+ char *buf = malloc(MAX_FILENAME_SIZE + strlen("_lock"));
+ char *pathname = malloc(MAX_PATH_SIZE + MAX_FILENAME_SIZE + strlen("_lock"));
+ char *target = xseg_get_target(pfiled->xseg, req);
+
+ if (!buf || !pathname) {
+ fail(pfiled, io);
+ return;
+ }
+
+ strncpy(buf, target, req->targetlen);
+ strncpy(buf+req->targetlen, "_lock", strlen("_lock"));
+
+ if (create_path(pathname, pfiled->vpath, buf, req->targetlen + strlen("_lock"), 1) < 0) {
+ goto out_fail;
+ }
+ unlink(pathname);
+ free(buf);
+ free(pathname);
+ complete(pfiled, io);
+ return;
+
+out_fail:
+ free(buf);
+ free(pathname);
+ fail(pfiled, io);
+ return;
+}
+