sysfs

Portable way to determine sector size in Linux

て烟熏妆下的殇ゞ 提交于 2019-12-11 05:52:43
问题 I want to write a small program in C which can determine the sector size of a hard disk. I wanted to read the file located in /sys/block/sd[X]/queue/hw_sector_size , and it worked in CentOS 6/7. However when I tested in CentOS 5.11, the file hw_sector_size is missing, and I have only found max_hw_sectors_kb and max_sectors_kb . Thus, I'd like to know how can I determine (APIs) the sector size in CentOS 5, or is there an other better way to do so. Thanks. 回答1: The fdisk utility displays this

Beaglebone gpio input not working

送分小仙女□ 提交于 2019-12-10 20:07:14
问题 I am using beaglebone to access digital input from specific pin using sysfs interface. And I can change the output states but not the input :(. What I did is, I have two pins pinA and pinB. pinA I made it output and pinB I made input. Connected pinA to pinB. Configured pinA as output pin by sending out to direction attribute in sysfs and pinB as input by passing in. And I changed value of PinA to 1 and it is giving 1 as output (I tested using LED). But when I read the value of PinB it is

My attributes are way too racy, what should I do?

梦想与她 提交于 2019-12-09 14:21:58
问题 In a linux device driver, creating sysfs attributes in probe is way too racy--specifically, it experiences a race condition with userspace. The recommended workaround is to add your attributes to various default attribute groups so they can be automatically created before probe. For a device driver, struct device_driver contains const struct attribute_group **groups for this purpose. However, struct attribute_group only got a field for binary attributes in Linux 3.11. With older kernels

Under what conditions would /sys/kernel/debug/gpio be empty?

最后都变了- 提交于 2019-12-07 06:32:10
问题 Summary My aim is to control the GPIO pins in Peppermint 4 Linux (Kernel version 3.8.0) on an Intel motherboard (NM70 chipset with C1037U processor). I'm debugging issues I'm having using the sysfs interface and am trying to understand the conditions where /sys/kernel/debug/gpio would be empty? When attempting to export pins 0 to 255 by echo XX > /sys/class/gpio/export for XX from 0 to 255, I get the following error message echo: write error: No such device Under what conditions would /sys

How to create a folder within a folder in sysfs

烈酒焚心 提交于 2019-12-06 11:23:32
问题 I am trying to create a sysfs for an implementation of mine in android and stuck at creating a folder of my own in CLASS . My requirement: /sys/class/example_class/my_sysfs_directory/file_one. Code: #include<linux/module.h> #include<linux/kernel.h> #include<linux/device.h> #include <linux/err.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("Manoj"); static ssize_t sysfs_demo_show(struct class *class, struct class_attribute *attr, char *buf) { pr_info("%s [%d]: \n", __func__, __LINE__); return sprintf

Create sysfs entry from kernel module

夙愿已清 提交于 2019-12-06 08:01:40
I want to pass a string > 1024 chars to my module (filesystem). As kernel parameters are limited to 1024 chars, someone recommended to use sysfs instead. I tried to include this example in my super.c class to create a string 'filename' & string 'code' entry in sysfs for my module. static decl_subsys(myfs, NULL, NULL); struct myfs_attr { struct attribute attr; char *value; }; static struct myfs_attr fname = { .attr.name="filename", .attr.owner = THIS_MODULE, .attr.mode = 0644, .value = "/my/test/path", }; static struct myfs_attr code = { .attr.name="code", .attr.owner = THIS_MODULE, .attr.mode

poll() on raspberry-gpio (sysfs) raspberry

主宰稳场 提交于 2019-12-06 05:27:51
as the title states, I have a problem porting some userspace-interrupt code from another armv7 embedded linux platform onto the Raspberry Pi 2 Model B. I'm aware of the wiringPi library (and got it to work that way), but for evaluation reasons I want to do run as much identical code as possible on both platforms. For that reason I have to interface with sysfs by hand. So, here's the relevant code snippet #define GPIO_TRIGGER_MODE "rising" #define SYS_GPIO_PIN "2" #define SYS_GPIO_DIRECTION "/sys/class/gpio/gpio2/direction" #define SYS_GPIO_EDGE "/sys/class/gpio/gpio2/edge" #define SYS_GPIO

How to send HDMI-CEC commands from Amlogic 905x board to the TV using sysfs

不问归期 提交于 2019-12-05 03:48:57
问题 I want to send raw HDMI-CEC commands (adb shell) from an Amlogic 905x ARM board (Android 6) to test the functionality. The board is rooted (tested, 'adb root' works) and connected to a TV with CEC capabilities (enabled, tested with video game console too). First of all I want to clarify if the core functionality is built in, so I guess that if the right CEC command is sent to the right channel, I should notice a change of any kind to the TV set. I want to test it at a lower abstraction level

How to create a folder within a folder in sysfs

孤街醉人 提交于 2019-12-04 15:19:25
I am trying to create a sysfs for an implementation of mine in android and stuck at creating a folder of my own in CLASS . My requirement: /sys/class/example_class/my_sysfs_directory/file_one. Code: #include<linux/module.h> #include<linux/kernel.h> #include<linux/device.h> #include <linux/err.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("Manoj"); static ssize_t sysfs_demo_show(struct class *class, struct class_attribute *attr, char *buf) { pr_info("%s [%d]: \n", __func__, __LINE__); return sprintf(buf, "%s \n", __func__); } static ssize_t sysfs_demo_store(struct class *class, struct class_attribute

How to attach file operations to sysfs attribute in platform driver?

我只是一个虾纸丫 提交于 2019-11-30 13:25:34
问题 I wrote a platform driver for a peripheral we developed and would like to expose some configuration options to the sysfs. I have managed to create the appropriate files using attribute structs (see below) and sysfs_create_file in the probe function, but I can't figure out how to attach the show/store functions to the structs in a platform driver. Most resources I found online used a device_attribute struct or something similar to create their files, is that also appropriate here? Is there