Branch data Line data Source code
1 : : // SPDX-License-Identifier: Apache-2.0
2 : : /* Copyright 2013-2017 IBM Corp.
3 : : */
4 : :
5 : : #include <stdlib.h>
6 : : #include <stdio.h>
7 : : #include <limits.h>
8 : : #include <unistd.h>
9 : : #include <dirent.h>
10 : : #include <sys/types.h>
11 : : #include <sys/stat.h>
12 : : #include <fcntl.h>
13 : : #include <string.h>
14 : :
15 : : #include <libflash/file.h>
16 : :
17 : : #include "arch_flash.h"
18 : :
19 : 11 : int arch_flash_init(struct blocklevel_device **r_bl, const char *file, bool keep_alive)
20 : : {
21 : 11 : int rc;
22 : 11 : struct blocklevel_device *new_bl;
23 : :
24 : : /* Must have passed through a file to operate on */
25 : 11 : if (!file) {
26 : 0 : fprintf(stderr, "Cannot operate without a file\n");
27 : 0 : return -1;
28 : : }
29 : :
30 : 11 : rc = file_init_path(file, NULL, keep_alive, &new_bl);
31 : 11 : if (rc)
32 : : return -1;
33 : :
34 : 11 : *r_bl = new_bl;
35 : 11 : return 0;
36 : : }
37 : :
38 : 11 : void arch_flash_close(struct blocklevel_device *bl, const char *file)
39 : : {
40 : 11 : (void)file;
41 : 11 : file_exit_close(bl);
42 : 11 : }
|