block-device

Retrieve correct Amazon attached EBS device from instance metadata endpoint

怎甘沉沦 提交于 2019-12-23 10:19:51
问题 EDIT and TL;DR: ubuntu@ip-172-31-19-77:~/.aws$ aws ec2 describe-instances | jq . | grep -i device "BlockDeviceMappings": [], "RootDeviceType": "ebs", "RootDeviceName": "/dev/sda1", "DeviceIndex": 0, "BlockDeviceMappings": [ "DeviceName": "/dev/sda1", "DeviceName": "/dev/xvdb", "RootDeviceType": "ebs", "RootDeviceName": "/dev/sda1", "DeviceIndex": 0, "BlockDeviceMappings": [ "DeviceName": "/dev/sda1", "RootDeviceType": "ebs", "RootDeviceName": "/dev/sda1", "DeviceIndex": 0,

Linux Kernel: Get real path behind a symlink

霸气de小男生 提交于 2019-12-12 12:02:59
问题 I'm working on some linux kernel stuff and I have a fake path called /dev/blah/whatever that points to /dev/block/real_device The issue is that lookup_bdev will fail to follow the symlink so I'd like to massage the path upfront by getting the real path (/dev/block/real_device) so I can hand that off to lookup_bdev so it returns successfully instead of an error. Or any other kernel call that would correctly retrieve the block_device information given the initial path. Thanks 回答1: Use VFS layer

Concurrent writes to a file using multiple threads

孤街醉人 提交于 2019-12-12 09:39:48
问题 I have a userlevel program which opens a file using the flags O_WRONLY|O_SYNC . The program creates 256 threads which attempt to write 256 or more bytes of data each to the file. I want to have a total of 1280000 requests, making it a total of about 300 MB of data. The program ends once 1280000 requests have been completed. I use pthread_spin_trylock() to increment a variable which keeps track of the number of requests that have been completed. To ensure that each thread writes to a unique

Concurrent writes to a file using multiple threads

佐手、 提交于 2019-12-05 17:58:28
I have a userlevel program which opens a file using the flags O_WRONLY|O_SYNC . The program creates 256 threads which attempt to write 256 or more bytes of data each to the file. I want to have a total of 1280000 requests, making it a total of about 300 MB of data. The program ends once 1280000 requests have been completed. I use pthread_spin_trylock() to increment a variable which keeps track of the number of requests that have been completed. To ensure that each thread writes to a unique offset, I use pwrite() and calculate the offset as a function of the number of requests that have been

Getting live info from /dev/input

雨燕双飞 提交于 2019-12-01 16:22:55
I am unsure if this is the correct place for this question. I am attempting to obtain the axis position values from a joystick /dev/input/js0 on my system. If I run jstest /dev/input/js0 it will give me live feedback on all buttons and axis positions. I am trying to feed this information into my C program to control servos. Is there a function for doing this? I have not worked much with input devices in programming so this is all new to me. This page: http://scaryreasoner.wordpress.com/2008/02/22/programming-joysticks-with-linux/ has a nice writeup on how to read the info from /dev/input/js0

Getting live info from /dev/input

穿精又带淫゛_ 提交于 2019-12-01 15:25:28
问题 This question was migrated from Unix & Linux Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . I am unsure if this is the correct place for this question. I am attempting to obtain the axis position values from a joystick /dev/input/js0 on my system. If I run jstest /dev/input/js0 it will give me live feedback on all buttons and axis positions. I am trying to feed this information into my C program to control servos. Is there a function for doing this? I have

Block device information without mounting in Linux

别来无恙 提交于 2019-12-01 04:04:13
问题 I am trying to get some information (specifically block size) of block device in linux, in C++. Is it possible to get block size of a device without mounting it and possibly without looking into dynamic files (like the ones in /sys ), but with a system call only. I was trying with stat , but it returns data about /dev filesystem if I ask about /dev/sdb2 . If it's impossible with system call, where should i look in dynamic files (haven't been able to locate it either.) 回答1: You want to use

Block device information without mounting in Linux

末鹿安然 提交于 2019-11-29 11:04:36
I am trying to get some information (specifically block size) of block device in linux, in C++. Is it possible to get block size of a device without mounting it and possibly without looking into dynamic files (like the ones in /sys ), but with a system call only. I was trying with stat , but it returns data about /dev filesystem if I ask about /dev/sdb2 . If it's impossible with system call, where should i look in dynamic files (haven't been able to locate it either.) themel You want to use ioctl , in particular BLKSSZGET . Quoting linux/fs.h: #define BLKSSZGET _IO(0x12,104)/* get block device

devicePolicyManager.lockNow() is not working for Motorola Tablets

寵の児 提交于 2019-11-27 02:20:41
问题 public final static void lockDevice() { try { if (devicePolicyManager.isAdminActive(adminComponent)) { devicePolicyManager.lockNow(); } } catch (final Exception ex) { ... } } The above code does not throw any exception nor it locks the screen for motorola xoom tablets only. (Both Homeycomb and Icecream Sandwitch) The same code works perfectly on other Homeycomb and ICS tablets. I googled, but did not get any solution. Any Ideas.....? 回答1: Possible reasons for this problem 1) I think there is