[OmniOS-discuss] LX Zone DTrace
Natxo Asenjo
natxo.asenjo at gmail.com
Sat Jan 14 14:35:34 UTC 2017
hi,
On Sat, Jan 14, 2017 at 3:16 PM, Mini Trader <miniflowtrader at gmail.com>
wrote:
> Well the author at my request was able to remove the call to os.getcwd()
> which allows the program to operate.
>
>
> If anyone wants to tinker here is an example that will likely break on
> someones system. I don't know if this is an LX bug, libc bug, python bug
> etc.
>
> # read a directory, stat all files
>
> import os
> import sys
> from stat import *
>
> def chdir(d):
> global cwdlist
>
> if d != '.':
> os.chdir(d)
> if d == '..':
> cwdlist.pop()
> else:
> cwdlist.append(d)
> print repr('/'.join(cwdlist))
> # Comment the line below to allow things to run
> os.getcwd()
>
> def walk(d):
> chdir(d)
> dirlist = os.listdir('.')
> dirlist.sort()
> for f in dirlist:
> try:
> s = os.lstat(f)
> if S_ISDIR(s.st_mode):
> walk(f)
> except OSError, err:
> print err
> chdir('..')
>
> if len(sys.argv) != 2:
> print 'need 1 arg, directory to scan'
>
> os.chdir(sys.argv[1])
> cwd = os.getcwd()
> cwdlist = cwd.split('/')
>
> walk('.')
>
>
runs fine in a centos 6.8 container, no problem.
I even have a couple of mount points with several thousand files and it
walks everything without a hitch.
--
regards,
Natxo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://omniosce.org/ml-archive/attachments/20170114/fdb5e0b2/attachment.html>
More information about the OmniOS-discuss
mailing list