MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dump_cachefile

Function dump_cachefile

freebsd/contrib/openzfs/cmd/zdb/zdb.c:3876–3920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3874}
3875
3876static void
3877dump_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

Callers 1

mainFunction · 0.85

Calls 9

fstat64Function · 0.85
mallocFunction · 0.85
dump_nvlistFunction · 0.85
printfFunction · 0.50
readFunction · 0.50
closeFunction · 0.50
nvlist_unpackFunction · 0.50
freeFunction · 0.50
nvlist_freeFunction · 0.50

Tested by

no test coverage detected