mbootuz.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:mbootuz 作者: ckhung 项目源码 文件源码
def find_boot_files(name, shortname, basedir):
# find vmlinuz or initrd
    if name:
        fullpath = name if name[0]=='/' else basedir + '/boot/' + name
    else:
        # try the (only) symlink at the root directory
        try1 = basedir + '/' + shortname + '*'
        found = sorted(glob.glob(try1))
        if len(found) >= 1 and os.access(found[0], os.R_OK):
            fullpath = os.path.realpath(found[0])
        else:
            # try the highest numbered version at /boot
            try2 = basedir + '/boot/' + shortname + '*'
            found = sorted(glob.glob(try2))
            if len(found) < 1:
                sys.exit('cannot read ' + try1 + ' and cannot find ' + try2)
            fullpath = found[-1]
            if (len(found) > 1):
                warnings.warn('found more than one ' + try2 + ' , using ' + fullpath)
    if not os.access(fullpath, os.R_OK):
        sys.exit('failed to read ' + fullpath)
    return fullpath
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号