MCPcopy Create free account
hub / github.com/coreboot/coreboot / open_cbfs

Function open_cbfs

util/nvramtool/cbfs.c:112–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void open_cbfs(const char *filename)
113{
114 struct stat cbfs_stat;
115 int cbfs_fd;
116
117 cbfs_fd = open(filename, O_RDWR);
118 if (cbfs_fd == -1) {
119 printf("Couldn't open '%s'\n", filename);
120 exit(-1);
121 }
122 if (fstat(cbfs_fd, &cbfs_stat) == -1) {
123 printf("Couldn't stat '%s'\n", filename);
124 exit(-1);
125 }
126 cbfs_mapped = mmap(NULL, cbfs_stat.st_size, PROT_READ | PROT_WRITE,
127 MAP_SHARED, cbfs_fd, 0);
128 close(cbfs_fd);
129 if (cbfs_mapped == MAP_FAILED) {
130 printf("Couldn't map '%s'\n", filename);
131 exit(-1);
132 }
133 cbfs_offset = cbfs_mapped-(0xffffffff-cbfs_stat.st_size+1);
134}

Callers 1

mainFunction · 0.85

Calls 2

printfFunction · 0.85
exitFunction · 0.85

Tested by

no test coverage detected