Commit 3094dd56 authored by Xavier Thompson's avatar Xavier Thompson

Simplify scan-filsystem

parent 4ffdaae6
......@@ -33,7 +33,7 @@ cdef cypclass Node activable:
self.path = path
self.stat = stat
void build_node(self, lock List[dev_t] dev_whitelist, lock List[Str] ignore_paths): pass
void build_node(self): pass
void format_node(self):
self.json = format("""\
......@@ -76,17 +76,7 @@ cdef cypclass DirNode(Node):
Node.__init__(self, path, stat)
self.children = Children()
void build_node(self, lock List[dev_t] dev_whitelist, lock List[Str] ignore_paths):
if ignore_paths is not NULL:
if consume self.path.copy() in ignore_paths:
return
if dev_whitelist is not NULL:
if self.stat is NULL:
return
elif not self.stat.st_data.st_dev in dev_whitelist:
return
void build_node(self):
entries = sys.listdir(self.path)
if entries is not NULL:
for name in entries:
......@@ -104,7 +94,7 @@ cdef cypclass DirNode(Node):
self.format_node()
for active_child in self.children:
active_child.build_node(NULL, dev_whitelist, ignore_paths)
active_child.build_node(NULL)
void write_node(self, FILE * stream):
sys.write(self.json, stream)
......@@ -129,7 +119,7 @@ cdef cypclass FileNode(Node):
Node.__init__(self, path, stat)
self.error = False
void build_node(self, lock List[dev_t] dev_whitelist, lock List[Str] ignore_paths):
void build_node(self):
cdef bint md5_ok
cdef bint sha1_ok
cdef bint sha256_ok
......@@ -208,7 +198,7 @@ cdef cypclass FileNode(Node):
cdef cypclass SymlinkNode(Node):
Str target
void build_node(self, lock List[dev_t] dev_whitelist, lock List[Str] ignore_paths):
void build_node(self):
self.target = sys.readlink(self.path, self.stat.st_data.st_size)
self.format_node()
......@@ -234,29 +224,13 @@ cdef cypclass SymlinkNode(Node):
cdef int scan(iso Str root) nogil:
ignore_paths = List[Str]()
ignore_paths.append(Str("/opt/slapgrid"))
ignore_paths.append(Str("/srv/slapgrid"))
dev_whitelist_paths = List[Str]()
dev_whitelist_paths.append(Str("."))
dev_whitelist_paths.append(Str("/"))
dev_whitelist_paths.append(Str("/boot"))
dev_whitelist = List[dev_t]()
for p in dev_whitelist_paths:
p_stat = Stat(p)
if p_stat is not NULL:
p_dev = p_stat.st_data.st_dev
dev_whitelist.append(p_dev)
node = make_node(consume root)
if node is NULL:
return -1
active_node = activate(consume node)
active_node.build_node(NULL, consume dev_whitelist, consume ignore_paths)
active_node.build_node(NULL)
scheduler.join()
......
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