ia64/xen-unstable

changeset 16296:ba1b6f9d33f5

acm, xend: Follow linked files.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author Keir Fraser <keir@xensource.com>
date Thu Nov 01 09:37:47 2007 +0000 (2007-11-01)
parents 76f30b65854f
children 2a5461071ca4
files tools/python/xen/util/xsm/acm/acm.py
line diff
     1.1 --- a/tools/python/xen/util/xsm/acm/acm.py	Thu Nov 01 09:36:46 2007 +0000
     1.2 +++ b/tools/python/xen/util/xsm/acm/acm.py	Thu Nov 01 09:37:47 2007 +0000
     1.3 @@ -711,33 +711,24 @@ def unify_resname(resource, mustexist=Tr
     1.4          except:
     1.5              err("Resource spec '%s' contains no tap subtype" % resource)
     1.6  
     1.7 -    import os
     1.8 -    if typ in ["phy", "tap"]:
     1.9 +    if typ in ["phy"]:
    1.10          if not resfile.startswith("/"):
    1.11              resfile = "/dev/" + resfile
    1.12          if mustexist:
    1.13 -            stats = os.lstat(resfile)
    1.14 -            if stat.S_ISLNK(stats[stat.ST_MODE]):
    1.15 -                resolved = os.readlink(resfile)
    1.16 -                if resolved[0] != "/":
    1.17 -                    resfile = os.path.join(os.path.dirname(resfile), resolved)
    1.18 -                    resfile = os.path.abspath(resfile)
    1.19 -                else:
    1.20 -                    resfile = resolved
    1.21 +            resfile = os.path.realpath(resfile)
    1.22 +            try:
    1.23                  stats = os.lstat(resfile)
    1.24 -            if not (stat.S_ISBLK(stats[stat.ST_MODE])):
    1.25 +                if not (stat.S_ISBLK(stats[stat.ST_MODE])):
    1.26 +                    err("Invalid resource")
    1.27 +            except:
    1.28                  err("Invalid resource")
    1.29  
    1.30      if typ in [ "file", "tap" ]:
    1.31 -        if mustexist:
    1.32 -            stats = os.lstat(resfile)
    1.33 -            if stat.S_ISLNK(stats[stat.ST_MODE]):
    1.34 -                resfile = os.readlink(resfile)
    1.35 -                stats = os.lstat(resfile)
    1.36 -            if not stat.S_ISREG(stats[stat.ST_MODE]):
    1.37 -                err("Invalid resource")
    1.38 +        resfile = os.path.realpath(resfile)
    1.39 +        if mustexist and not os.path.isfile(resfile):
    1.40 +            err("Invalid resource")
    1.41  
    1.42 -    #file: resources must specified with absolute path
    1.43 +    #file: resources must be specified with absolute path
    1.44      #vlan resources don't start with '/'
    1.45      if typ != "vlan":
    1.46          if (not resfile.startswith("/")) or \