Skip to content

Commit 2f582e0

Browse files
authored
Merge pull request torvalds#353 from M1cha/encode-dev
make 'encode_dev_from_sysfs' a public library function
2 parents 410bc30 + dcf160c commit 2f582e0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tools/lkl/include/lkl.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ int lkl_disk_add(struct lkl_disk *disk);
127127
*/
128128
int lkl_disk_remove(struct lkl_disk disk);
129129

130+
/**
131+
* lkl_get_virtiolkl_encode_dev_from_sysfs_blkdev - extract device id from sysfs
132+
*
133+
* This function returns the device id for the given sysfs dev node.
134+
* The content of the node has to be in the form 'MAJOR:MINOR'.
135+
* Also, this function expects an absolute path which means that sysfs
136+
* already has to be mounted at the given path
137+
*
138+
* @sysfs_path - absolute path to the sysfs dev node
139+
* @pdevid - pointer to memory where dev id will be returned
140+
* @returns - 0 on success, a negative value on error
141+
*/
142+
int lkl_encode_dev_from_sysfs(const char *sysfs_path, uint32_t *pdevid);
143+
130144
/**
131145
* lkl_get_virtio_blkdev - get device id of a disk (partition)
132146
*

tools/lkl/lib/fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int get_node_with_prefix(const char *path, const char *prefix,
7474
return ret;
7575
}
7676

77-
static int encode_dev_from_sysfs(const char *sysfs_path, uint32_t *pdevid)
77+
int lkl_encode_dev_from_sysfs(const char *sysfs_path, uint32_t *pdevid)
7878
{
7979
int ret;
8080
long fd;
@@ -191,7 +191,7 @@ int lkl_get_virtio_blkdev(int disk_id, unsigned int part, uint32_t *pdevid)
191191
if (ret)
192192
return ret;
193193

194-
return encode_dev_from_sysfs(sysfs_path, pdevid);
194+
return lkl_encode_dev_from_sysfs(sysfs_path, pdevid);
195195
}
196196

197197
long lkl_mount_dev(unsigned int disk_id, unsigned int part,

0 commit comments

Comments
 (0)