On Wed, Jun 15, 2011 at 12:29 PM, Andy Lutomirski <luto@mit.edu> wrote:>> Well, the man page says that the version parameter is used to find> /lib/modules/version. So why not check if /lib/modules/version exists and,> if not, try the filename?

Yeah, that's the only sane way to see if something is a filename: lookup the file. If you can find it, it's a filename.

It's what 'git' uses to decide between the ambiguity of a filename vsa commit name, for example. It works really well. And sometimes, whenthe ambiguity is not resolvable (ie you really meant a filename, butthere's a version that has the exact same format), then you arefundamentally screwed - you need some other way to tell the difference(which could be a simple priority decision - "filename overridesversion" - or it can be a command line thing).

So stop trying to parse the version number, and just see if'/lib/modules/%s' exists for that (unparsed) version string. Or, ifyou want to prioritize it the other way, just check for existence ofthe file of the (again, unparsed) version string with a simple"access(%s, F_OK)" or something.