We still have name allocated just after the struct kmod_module, but
now we use a pointer instead of putting name as a vector in the end of
the structure.
The previous way has some problems, the worst is:
- it's not possible to swap the name with another value: this is
the real problem that this patch is solving. Later patches
will make name be swappable with alias, which is not possible
if name is a vector.
*/
struct kmod_module {
struct kmod_ctx *ctx;
+ char *name;
char *path;
struct kmod_list *dep;
char *options;
bool install_commands : 1;
bool remove_commands : 1;
} init;
- char name[];
};
inline char *modname_normalize(const char *modname, char buf[NAME_MAX],
}
m->ctx = kmod_ref(ctx);
+ m->name = (char *)m + sizeof(*m);
memcpy(m->name, name_norm, namelen + 1);
m->refcount = 1;
return -errno;
m->ctx = kmod_ref(ctx);
+ m->name = (char *)m + sizeof(*m);
memcpy(m->name, name, namelen);
m->path = abspath;
m->refcount = 1;