Commit acbd78df authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

make static nodes using udev rules

parent 9a148fa2
......@@ -19,7 +19,7 @@
@author: Andrey Filippov
@copyright: 2016 Elphel, Inc.
@license: GPLv3.0+
@contact: andrey@elphel.coml
@contact: andrey@elphel.com
@deffield updated: Updated
'''
from __future__ import division
......@@ -34,7 +34,26 @@ __version__ = "3.0+"
__maintainer__ = "Andrey Filippov"
__email__ = "andrey@elphel.com"
__status__ = "Development"
def create_udev_rules_file(contents):
c = "# --- This is an auto-generated file, see "+sys.argv[0]+"\n"
c += "ACTION!=\"add\", GOTO=\"static_nodes_end\"\n\n"
c += contents
c += "\nLABEL=\"static_nodes_end\""
f = open('50-elphel-static-nodes.rules','w')
f.write(c)
f.close()
def get_udev_rule(mode, name, devtype, major, minor,comment):
tmpstr = comment.strip()+"\n"
tmpstr += "ACTION==\"add\", RUN+=\"/bin/mknod -m "+mode+" /dev/"+name+" "+devtype+" "+major+" "+minor+"\"\n"
return tmpstr
def process_header():
rulestr = ""
print("# --- This is an auto-generated file, see %s ---"%(sys.argv[0]))
print("define mknodes =")
pat=re.compile(r'#define\s+(\w+)\s+\(\s*"([^"]+)"\s*,\s*"([^"]+)"\s*,\s*(\w*)\s*,\s*(\w*)\s*,\s*"([^"]+)"\s*,\s*"([^"]+)"\s*\)(.*)')
......@@ -52,7 +71,14 @@ def process_header():
comment = " # "+comment
print("mknod -m %s $(TARGETDIR)/%-20s %s %3s %3s%s"%(
fs.group(6), fs.group(2), fs.group(7), fs.group(4), fs.group(5), comment))
rulestr += get_udev_rule(fs.group(6), fs.group(2), fs.group(7), fs.group(4), fs.group(5), comment)
line = f.readline()
if rulestr != "":
create_udev_rules_file(rulestr)
print("endef")
if __name__ == "__main__":
process_header()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment