| 3874 | } |
| 3875 | |
| 3876 | static void |
| 3877 | dump_cachefile(const char *cachefile) |
| 3878 | { |
| 3879 | int fd; |
| 3880 | struct stat64 statbuf; |
| 3881 | char *buf; |
| 3882 | nvlist_t *config; |
| 3883 | |
| 3884 | if ((fd = open64(cachefile, O_RDONLY)) < 0) { |
| 3885 | (void) printf("cannot open '%s': %s\n", cachefile, |
| 3886 | strerror(errno)); |
| 3887 | exit(1); |
| 3888 | } |
| 3889 | |
| 3890 | if (fstat64(fd, &statbuf) != 0) { |
| 3891 | (void) printf("failed to stat '%s': %s\n", cachefile, |
| 3892 | strerror(errno)); |
| 3893 | exit(1); |
| 3894 | } |
| 3895 | |
| 3896 | if ((buf = malloc(statbuf.st_size)) == NULL) { |
| 3897 | (void) fprintf(stderr, "failed to allocate %llu bytes\n", |
| 3898 | (u_longlong_t)statbuf.st_size); |
| 3899 | exit(1); |
| 3900 | } |
| 3901 | |
| 3902 | if (read(fd, buf, statbuf.st_size) != statbuf.st_size) { |
| 3903 | (void) fprintf(stderr, "failed to read %llu bytes\n", |
| 3904 | (u_longlong_t)statbuf.st_size); |
| 3905 | exit(1); |
| 3906 | } |
| 3907 | |
| 3908 | (void) close(fd); |
| 3909 | |
| 3910 | if (nvlist_unpack(buf, statbuf.st_size, &config, 0) != 0) { |
| 3911 | (void) fprintf(stderr, "failed to unpack nvlist\n"); |
| 3912 | exit(1); |
| 3913 | } |
| 3914 | |
| 3915 | free(buf); |
| 3916 | |
| 3917 | dump_nvlist(config, 0); |
| 3918 | |
| 3919 | nvlist_free(config); |
| 3920 | } |
| 3921 | |
| 3922 | /* |
| 3923 | * ZFS label nvlist stats |
no test coverage detected