문제

I am writing Linux Kernel module, where I'm creating some sysfs files to store variables.

But I need to implement arrays, something like:

struct ats {
   struct attribute attr;
   unsigned long value[5];
};

struct ats m_ats = {
   .attr.name="m_ats",
   .attr.mode = 0644,
   .value[0] = 0,
   .value[1] = 0,
   .value[2] = 0,
   .value[3] = 0,
   .value[4] = 0,
};

Is there a way to do that? How would be the show, store, module_init, module_exit functions?

도움이 되었습니까?

해결책

You have to do it manually. You can use sscanf on the incoming string, parse the input and store each value in the array slot. Something like this:

sscanf(input_string, "%d %d %d", value[0], value[1], value[3])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top