1

So I have been reading into Linux APIs (syscalls and libc) as well as device ioctls., calling ioctls via create(dev_name) and ioctl(device_file_handle) and the sysfs file system. So here are my questions:

  1. Is sysfs 'supposed' to be a read only where various Kernel parameters are exposed to be read ? Or are they 'supposed' to be writable too ?

  2. Are all drivers in future required to expose interfaces in sysfs ?

  3. If the answer to the above is true, then would we be really requiring IOCTL calls at all anymore? because all that we would need to do to make a driver do something is to change values in some of the files in sysfs, e.g., To call a ioctl called DO_SOMETHING on driver D1, we would be doing :

    echo 1> /sysfs/D1/IOCTLS/DO_SOMETHING  ( or something like that ... :) )   
    
  4. Are there any plans of exposing the kernel API (that is syscalls and libc ) as sysfs files, e.g.,

    echo 1> /sysfs/libc/get_system_time 
    cat /sysfs/libc/results/system_time     
    

    Would it be a good idea to do this ?

  5. Is there any sysfs like system in Windows ? Or any ongoing projects maybe?

  6. How about exposing core system calls , libc and any new libraries over http ? ( Just wanted a frank discussion on this idea)

Abhijeet Kasurde
  • 3,937
  • 1
  • 24
  • 33
linux
  • 11
  • 3

3 Answers3

1
  1. a) No. b) It depends.
  2. I didn't hear about such requirement.
  3. You have to provide a protocol to exchange between caller and kernel. You may check how it's done in Plan9. We will require IOCTL, read more about this on SO answer
  4. Have you given a thought about security? It will be a big hole in the OS I presume.
  5. Out of my knowledge.
  6. Won't discuss.
Community
  • 1
  • 1
0andriy
  • 4,183
  • 1
  • 24
  • 37
1

1 - > No sysfs can be implemented for write also . User can use it something like this . echo " Hello" > /sys/devices/***/sysfs_entry

2 -> No I think most of the platform related drivers open sysfs interfaces

3 -> Answer to above question in No . We still need ioctls .

4 -> I believe only the useful API's with some feature involved are exposed as sysfs entries. For example the device behind the driver has 100 registers. Each registers are not exposed as sysfs entries. But if there are 3-4 features involving these registers those features are exposed as sysfs entries. These entries should not cause any errors / panic on wrong data . That responsibility is there on the developer.

5 -> No idea.

6 -> No idea.

0

Please find my inline reply of your questions:

1) We can perform both the read and write operation through sysfs; again it depends upon your requirements.

2) I don't think so; both sysfs and ioctl have there own advantages so you can not compare both in the same ways.

3) Its not true.

4)Sysfs APIs (show and store APIs)are already exposed to user space. you can call these APIs from user space.

5) It may be; but I am not sure.

vinod maverick
  • 670
  • 4
  • 14