Skip to content

Commit

Permalink
Merge pull request torvalds#353 from M1cha/encode-dev
Browse files Browse the repository at this point in the history
make 'encode_dev_from_sysfs' a public library function
  • Loading branch information
tavip authored Jul 10, 2017
2 parents 410bc30 + dcf160c commit 2f582e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tools/lkl/include/lkl.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ int lkl_disk_add(struct lkl_disk *disk);
*/
int lkl_disk_remove(struct lkl_disk disk);

/**
* lkl_get_virtiolkl_encode_dev_from_sysfs_blkdev - extract device id from sysfs
*
* This function returns the device id for the given sysfs dev node.
* The content of the node has to be in the form 'MAJOR:MINOR'.
* Also, this function expects an absolute path which means that sysfs
* already has to be mounted at the given path
*
* @sysfs_path - absolute path to the sysfs dev node
* @pdevid - pointer to memory where dev id will be returned
* @returns - 0 on success, a negative value on error
*/
int lkl_encode_dev_from_sysfs(const char *sysfs_path, uint32_t *pdevid);

/**
* lkl_get_virtio_blkdev - get device id of a disk (partition)
*
Expand Down
4 changes: 2 additions & 2 deletions tools/lkl/lib/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static int get_node_with_prefix(const char *path, const char *prefix,
return ret;
}

static int encode_dev_from_sysfs(const char *sysfs_path, uint32_t *pdevid)
int lkl_encode_dev_from_sysfs(const char *sysfs_path, uint32_t *pdevid)
{
int ret;
long fd;
Expand Down Expand Up @@ -191,7 +191,7 @@ int lkl_get_virtio_blkdev(int disk_id, unsigned int part, uint32_t *pdevid)
if (ret)
return ret;

return encode_dev_from_sysfs(sysfs_path, pdevid);
return lkl_encode_dev_from_sysfs(sysfs_path, pdevid);
}

long lkl_mount_dev(unsigned int disk_id, unsigned int part,
Expand Down

0 comments on commit 2f582e0

Please sign in to comment.