+ char cmd[4096] = "";
+
+ snprintf(cmd, sizeof(cmd), "../utils/lctl mark %s 2>/dev/null", msg);
+ return system(cmd);
+}
+
+/* verify a file contents */
+int check_access(const char *filename,
+ int mnt_fd, struct file_handle *fh, struct stat *st_orig)
+{
+ int fd2, rc, len, offset;
+ struct stat st;
+ char *readbuf = NULL;
+
+ debug_mark("before open by handle");
+ /* Open the file handle */
+ fd2 = open_by_handle_at(mnt_fd, fh, O_RDONLY |
+ (S_ISDIR(st_orig->st_mode) ? O_DIRECTORY : 0));
+ debug_mark("after open by handle");
+ if (fd2 < 0) {
+ fprintf(stderr, "open_by_handle_at(%s) error: %s\n", filename,
+ strerror(errno));
+ if (errno == ESTALE)
+ fprintf(stderr, "second mountpoint not mounted?\n");
+ rc = errno;
+ goto out_f_handle;
+ }
+
+ /* Get file size */
+ bzero(&st, sizeof(struct stat));
+ debug_mark("before stat");
+ rc = fstat(fd2, &st);
+ debug_mark("after stat");
+ if (rc < 0) {
+ fprintf(stderr, "fstat(%s) error: %s\n", filename,
+ strerror(errno));
+ rc = errno;
+ goto out_fd2;
+ }
+
+ /* we can't check a ctime due unlink update */
+ if (st_orig->st_size != st.st_size ||
+ st_orig->st_ino != st.st_ino ||
+ st_orig->st_mode != st.st_mode ||
+ st_orig->st_mtime != st.st_mtime) {
+ fprintf(stderr,
+ "stat data mismatch between fopen and fhandle case\n");
+ rc = EINVAL;
+ goto out_fd2;
+ }
+
+ if (st.st_size && S_ISREG(st.st_mode)) {
+ len = st.st_blksize;
+ readbuf = malloc(len);
+ if (readbuf == NULL) {
+ fprintf(stderr, "malloc(%d) error: %s\n", len,
+ strerror(errno));
+ rc = errno;
+ goto out_fd2;
+ }
+
+ for (offset = 0; offset < st.st_size; offset += len) {
+ /* read from the file */
+ rc = read(fd2, readbuf, len);
+ if (rc < 0) {
+ fprintf(stderr, "read(%s) error: %s\n",
+ filename, strerror(errno));
+ rc = errno;
+ goto out_readbuf;
+ }
+ }
+ }
+ rc = 0;
+out_readbuf:
+ free(readbuf);
+out_fd2:
+ close(fd2);
+out_f_handle:
+ return rc;