LDD3的解释:
is used to tell the kernel that this module bears a free license; without such a declaration, the kernel complains when the module is loaded.
外国人的解释:
Q:"How does MODULE_LICENSE work in the Linux kernel?"
A:The Linux kernel is under the GPL.<wbr> That means that the source is available to you, and you can do anything you like with it (Yay!).<wbr> One of the ways that Linux can be modified is by changing its source code.<wbr> Another, more common way is by writing a module.<wbr> Maybe you want to make a module that is a device drive for a USB missile launcher.<wbr> That'd be awesome.<wbr> Modules can be distributed separately and loaded into the linux kernel while the kernel is running, but modules can also be compiled into the linux kernel so they will permanently be part of its code.<br><br> If you write a USB missile launcher module, it's your own code, and you own it.<wbr> Since you're free to do whatever you want with the Linux code, and since you own the module, there's no reason you can't compile your module into the Linux kernel (Yay!).<wbr> Maybe you want to create a whole linux distribution based around launching USB missiles.<wbr> It'd have your module compiled into the kernel.<wbr> Maybe you'd add in some other modules, too.<wbr> Lots of device drivers from all around.<wbr> But wait, according to the GPL, if you distribute a linux kernel, everything compiled into it has to be available in source code.<wbr> Are all of the modules you added in available in source code form?<wbr> Uh-oh, you added a lot of modules.<wbr> Who even knows anymore?<br><br> Well, fortunately, the kernel you built knows whether or not it's still free to be redistributed.<wbr> Almost every modern module includes the MODULE_LICENSE() macro, which takes a string specifying its license (modules that don't include this line are presumed not free).<wbr> That way, when you load those modules in, the linux kernel knows that it's been tainted.<wbr> modutils and other tools examine these modules and check to see whether they're tained and how so.<br><br> The Linux kernel recognizes a handful of valid arguments that do not mark the kernel as tainted.<wbr> "GPL", "GPL v2", "Dual MIT/GPL", and a few others.<br><br> And so, to answer your question of "how does this prevent proprietary modules from being built into the kernel?"<wbr> It doesn't.<wbr> Proprietary modules will load just fine into a linux kernel.<wbr> But the kernel will remember, and somebody can check to see if the kernel is still free.<br><br> You can cheat, though.<wbr> You can pass the string "GPL" in to get rid of tainted module warnings.<wbr> It's dishonest, and it might even be used as a legal argument that your code IS now under the GPL, but the kernel isn't checking to see what license your code is actually under.<wbr> Don't do that, though.<wbr> Just say MODULE_LICENSE("Proprietary") and take the warning message.<wbr> Most users won't ever see it.<wbr> You can't distribute a linux kernel like that, either.<wbr> Somebody will catch you eventually.<wbr> Nerds have lots of free time.<br><br> Were you looking for a more technical answer to the question of how does the kernel know what string you passed into MODULE_LICENSE?<wbr> You can check that out yourself.<wbr> MODULE_LICENSE() is actually a specialized call to MODULE_INFO, which itself is a call to __MODULE_INFO, which is a macro for, well, it eventually settles out.<wbr> You can read it yourself: http://lxr.linux.no/source/include/linux/module.h#L126</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>