Pergunta

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?

Foi útil?

Solução

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])
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top