b0da854a7623f087875bf233db53c5881124fc50
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 static const char *const fit0
= "/dev/fit0";
8 static const char *const fitrw
= "/dev/fitrw";
19 struct devpath devpath
;
23 static struct driver fit_driver
;
25 static int fit_volume_identify(struct volume
*v
)
27 struct fit_volume
*p
= container_of(v
, struct fit_volume
, v
);
31 f
= fopen(p
->dev
.devpathstr
, "r");
35 ret
= block_file_identify(f
, 0);
42 static int fit_volume_init(struct volume
*v
)
44 struct fit_volume
*p
= container_of(v
, struct fit_volume
, v
);
48 snprintf(voldir
, sizeof(voldir
), "%s/%s", block_dir_name
, p
->dev
.devpath
.device
);
50 if (read_uint_from_file(voldir
, "size", &volsize
))
54 v
->size
= volsize
<< 9; /* size is returned in sectors of 512 bytes */
55 v
->blk
= p
->dev
.devpathstr
;
57 return block_volume_format(v
, 0, p
->dev
.devpathstr
);
60 static struct volume
*fit_volume_find(char *name
)
67 if (!strcmp(name
, "rootfs"))
69 else if (!strcmp(name
, "rootfs_data"))
74 ret
= stat(fname
, &buf
);
78 p
= calloc(1, sizeof(struct fit_volume
));
82 strcpy(p
->dev
.devpathstr
, fname
);
83 p
->v
.drv
= &fit_driver
;
84 p
->v
.blk
= p
->dev
.devpathstr
;
90 static struct driver fit_driver
= {
93 .find
= fit_volume_find
,
94 .init
= fit_volume_init
,
95 .identify
= fit_volume_identify
,