]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/sysfs.h
2 * Copyright (C) 2011 Karel Zak <kzak@redhat.com>
4 #ifndef UTIL_LINUX_SYSFS_H
5 #define UTIL_LINUX_SYSFS_H
12 #include <sys/types.h>
22 * sysfs_devname_sys_to_dev:
23 * @name: devname to be converted in place
25 * Linux kernel linux/drivers/base/core.c: device_get_devnode()
26 * defines a replacement of '!' in the /sys device name by '/' in the
27 * /dev device name. This helper replaces all occurrences of '!' in
28 * @name by '/' to convert from /sys to /dev.
30 static inline void sysfs_devname_sys_to_dev(char *name
)
35 while ((c
= strchr(name
, '!')))
40 * sysfs_devname_dev_to_sys:
41 * @name: devname to be converted in place
43 * See sysfs_devname_sys_to_dev().
45 static inline void sysfs_devname_dev_to_sys(char *name
)
50 while ((c
= strchr(name
, '/')))
56 struct path_cxt
*parent
;
58 unsigned int scsi_host
,
63 unsigned int has_hctl
: 1,
67 void ul_sysfs_init_debug(void);
69 struct path_cxt
*ul_new_sysfs_path(dev_t devno
, struct path_cxt
*parent
, const char *prefix
);
70 int sysfs_blkdev_init_path(struct path_cxt
*pc
, dev_t devno
, struct path_cxt
*parent
);
72 int sysfs_blkdev_set_parent(struct path_cxt
*pc
, struct path_cxt
*parent
);
73 struct path_cxt
*sysfs_blkdev_get_parent(struct path_cxt
*pc
);
75 char *sysfs_blkdev_get_name(struct path_cxt
*pc
, char *buf
, size_t bufsiz
);
76 int sysfs_blkdev_is_partition_dirent(DIR *dir
, struct dirent
*d
, const char *parent_name
);
77 int sysfs_blkdev_count_partitions(struct path_cxt
*pc
, const char *devname
);
78 dev_t
sysfs_blkdev_partno_to_devno(struct path_cxt
*pc
, int partno
);
79 char *sysfs_blkdev_get_slave(struct path_cxt
*pc
);
80 char *sysfs_blkdev_get_path(struct path_cxt
*pc
, char *buf
, size_t bufsiz
);
81 dev_t
sysfs_blkdev_get_devno(struct path_cxt
*pc
);
83 char *sysfs_blkdev_get_devchain(struct path_cxt
*pc
, char *buf
, size_t bufsz
);
84 int sysfs_blkdev_next_subsystem(struct path_cxt
*pc
__attribute__((unused
)), char *devchain
, char **subsys
);
86 int sysfs_blkdev_is_hotpluggable(struct path_cxt
*pc
);
87 int sysfs_blkdev_get_wholedisk( struct path_cxt
*pc
,
92 int sysfs_devno_to_wholedisk(dev_t dev
, char *diskname
,
93 size_t len
, dev_t
*diskdevno
);
94 int sysfs_devno_is_dm_private(dev_t devno
, char **uuid
);
95 int sysfs_devno_is_wholedisk(dev_t devno
);
96 dev_t
sysfs_devname_to_devno(const char *name
);
97 dev_t
__sysfs_devname_to_devno(const char *prefix
, const char *name
, const char *parent
);
98 char *sysfs_devno_to_devpath(dev_t devno
, char *buf
, size_t bufsiz
);
99 char *sysfs_devno_to_devname(dev_t devno
, char *buf
, size_t bufsiz
);
100 int sysfs_devno_count_partitions(dev_t devno
);
102 int sysfs_blkdev_scsi_get_hctl(struct path_cxt
*pc
, int *h
, int *c
, int *t
, int *l
);
103 char *sysfs_blkdev_scsi_host_strdup_attribute(struct path_cxt
*pc
,
104 const char *type
, const char *attr
);
105 int sysfs_blkdev_scsi_host_is(struct path_cxt
*pc
, const char *type
);
106 int sysfs_blkdev_scsi_has_attribute(struct path_cxt
*pc
, const char *attr
);
107 int sysfs_blkdev_scsi_path_contains(struct path_cxt
*pc
, const char *pattern
);
110 #endif /* UTIL_LINUX_SYSFS_H */