コード例 #1
0
 def addDriver(self, widget, *args):
     try:
         self.scanForDriverDisk()
     except InvalidDriverCDException, e:
         util.umount(MEDIA_DEVICE_MOUNT_POINT)
         cdutil.ejectCdrom()
         MessageWindow(None, "Invalid Driver CD", str(e))
コード例 #2
0
ファイル: usbmedia.py プロジェクト: vmware-archive/weasel
def findUSBMedia(showAll=False):
    """Scan attached USB devices for installation media.

    If showAll is True, all CD devices are returned even if they do not contain
    any installation media.
    """

    diskSet = devices.DiskSet(forceReprobe=True)

    retval = []

    util.umount(USB_MEDIA_PATH)
    for disk in diskSet.values():
        if disk.driverName != devices.DiskDev.DRIVER_USB_STORAGE:
            log.debug("skipping non-usb device -- %s" % disk.name)
            continue

        diskMedia = []
        for part in disk.partitions:
            if not part.consoleDevicePath:
                continue

            diskMedia += _tryDevice(disk, part)

        if not diskMedia and showAll:
            # No installation media was found on the device, but the caller
            # wants the list of potential media devices, so add that in.
            diskMedia = [media.MediaDescriptor(disk.name)]

        retval += diskMedia

    return retval
コード例 #3
0
def test_fusexmp_fh(tmpdir, name):
    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = [os.path.join(basename, 'example', name),
                '-f', '-o' , 'use_ino,readdir_ino,kernel_cache',
                mnt_dir ]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        work_dir = os.path.join(mnt_dir, src_dir)
        tst_write(work_dir)
        tst_mkdir(work_dir)
        tst_symlink(work_dir)
        tst_mknod(work_dir)
        if os.getuid() == 0:
            tst_chown(work_dir)
        # Underlying fs may not have full nanosecond resolution
        tst_utimens(work_dir, ns_tol=1000)
        tst_link(work_dir)
        tst_readdir(work_dir)
        tst_statvfs(work_dir)
        tst_truncate_path(work_dir)
        tst_truncate_fd(work_dir)
        tst_unlink(work_dir)
        tst_passthrough(src_dir, work_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #4
0
def test_notify_inval_entry(tmpdir, notify, output_checker):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', 'notify_inval_entry'),
                '-f', '--update-interval=1',
                '--timeout=5', mnt_dir ]
    if not notify:
        cmdline.append('--no-notify')
    mount_process = subprocess.Popen(cmdline,
                                     stdout=output_checker.fd,
                                     stderr=output_checker.fd)
    try:
        wait_for_mount(mount_process, mnt_dir)
        fname = pjoin(mnt_dir, os.listdir(mnt_dir)[0])
        try:
            os.stat(fname)
        except FileNotFoundError:
            # We may have hit a race condition and issued
            # readdir just before the name changed
            fname = pjoin(mnt_dir, os.listdir(mnt_dir)[0])
            os.stat(fname)

        safe_sleep(2)
        if not notify:
            os.stat(fname)
            safe_sleep(5)
        with pytest.raises(FileNotFoundError):
            os.stat(fname)
    except:
        cleanup(mount_process, mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #5
0
def test_tmpfs(tmpdir):
    mnt_dir = str(tmpdir)
    cmdline = [sys.executable,
               os.path.join(basename, 'examples', 'tmpfs.py'),
               mnt_dir ]
    mount_process = subprocess.Popen(cmdline, stdin=subprocess.DEVNULL,
                                     universal_newlines=True)
    try:
        wait_for_mount(mount_process, mnt_dir)
        tst_write(mnt_dir)
        tst_mkdir(mnt_dir)
        tst_symlink(mnt_dir)
        tst_mknod(mnt_dir)
        tst_chown(mnt_dir)
        tst_chmod(mnt_dir)
        tst_utimens(mnt_dir)
        tst_link(mnt_dir)
        tst_readdir(mnt_dir)
        tst_statvfs(mnt_dir)
        tst_truncate_path(mnt_dir)
        tst_truncate_fd(mnt_dir)
        tst_unlink(mnt_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #6
0
def _bootpartOption(match):
    uuid = match.group(1)
    if not util.uuidToDevicePath(uuid):
        failWithLog("error: cannot find device for UUID: %s\n" % uuid)
        
    userchoices.setBootUUID(uuid)

    mountPath = util.mountByUuid(uuid)
    if not mountPath:
        failWithLog("error: cannot mount boot partition with UUID -- %s" % uuid)

    restoredGrubConf = False
    for prefix in ("boot/grub", "grub"):
        path = os.path.join(mountPath, prefix, "grub.conf")
        if os.path.exists(path):
            tmpPath = os.tempnam(os.path.dirname(path), "grub.conf")
            os.symlink(os.path.basename(GRUB_CONF_PREV), tmpPath)
            # Use rename so the replacement is atomic.
            os.rename(tmpPath, path)
            restoredGrubConf = True
            break
    if not restoredGrubConf:
        log.warn("could not restore %s, upgrade failure will not "
                 "reboot into ESX v3" % GRUB_CONF_PREV)

    util.umount(mountPath)

    return []
コード例 #7
0
ファイル: usbmedia.py プロジェクト: vmware-archive/weasel
def _tryDevice(disk, part):
    devicePath = part.consoleDevicePath

    log.info("looking for installation data on %s" % devicePath)

    # Either the USB storage is the media itself or it might contain an ISO file
    # that is the installation media.
    usbDesc = media.MediaDescriptor(disk.name, devicePath,
                                    part.getFsTypeName())
    if usbDesc.probeForPackages():
        log.info("  found installation media...")
        return [usbDesc]

    # Be explicit about fsTypeName since long file names work if we mount it as
    # "vfat", but not when the auto-detection thinks it's "msdos".
    if util.mount(devicePath, USB_MEDIA_PATH,
                  fsTypeName=part.getFsTypeName()) != 0:
        return []

    retval = []
    for iso in glob.glob(os.path.join(USB_MEDIA_PATH, "*.iso")):
        isoDesc = media.MediaDescriptor(disk.name, devicePath,
                                        part.getFsTypeName(),
                                        os.path.basename(iso))
        if isoDesc.probeForPackages():
            log.info("  found iso, %s, with installation media..." % iso)
            retval.append(isoDesc)

    util.umount(USB_MEDIA_PATH)

    return retval
コード例 #8
0
def test_null(tmpdir, output_checker):
    progname = pjoin(basename, 'example', 'null')
    if not os.path.exists(progname):
        pytest.skip('%s not built' % os.path.basename(progname))

    mnt_file = str(tmpdir) + '/file'
    with open(mnt_file, 'w') as fh:
        fh.write('dummy')
    cmdline = base_cmdline + [progname, '-f', mnt_file]
    mount_process = subprocess.Popen(cmdline,
                                     stdout=output_checker.fd,
                                     stderr=output_checker.fd)

    def test_fn(name):
        return os.stat(name).st_size > 4000

    try:
        wait_for_mount(mount_process, mnt_file, test_fn)
        with open(mnt_file, 'rb') as fh:
            assert fh.read(382) == b'\0' * 382
        with open(mnt_file, 'wb') as fh:
            fh.write(b'whatever')
    except:
        cleanup(mount_process, mnt_file)
        raise
    else:
        umount(mount_process, mnt_file)
コード例 #9
0
ファイル: test_fs.py プロジェクト: hugovk/python-llfuse
def testfs(tmpdir):

    # We can't use forkserver because we have to make sure
    # that the server inherits the per-test stdout/stderr file
    # descriptors.
    if hasattr(multiprocessing, 'get_context'):
        mp = multiprocessing.get_context('fork')
    else:
        # Older versions only support *fork* anyway
        mp = multiprocessing
    if threading.active_count() != 1:
        raise RuntimeError("Multi-threaded test running is not supported")

    mnt_dir = str(tmpdir)
    with mp.Manager() as mgr:
        cross_process = mgr.Namespace()
        mount_process = mp.Process(target=run_fs,
                                   args=(mnt_dir, cross_process))

        mount_process.start()
        try:
            wait_for_mount(mount_process, mnt_dir)
            yield (mnt_dir, cross_process)
        except:
            cleanup(mnt_dir)
            raise
        else:
            umount(mount_process, mnt_dir)
コード例 #10
0
    def __init__(self, controlState, xml):
        controlState.displayHeaderBar = True
        controlState.windowIcon = 'customdrivers.png'
        controlState.windowTitle = 'Custom Drivers'
        controlState.windowText = \
            'Select custom drivers to install for ESX'

        self.xml = xml
        self.foundDriverList = []
        self.driverList = []            # list of drivers to save
        self.driverDict = {}            # cache of driver data

        connectSignalHandlerByDict(self, CustomDriversWindow, self.xml,
          { ('CustomdriversNoRadioButton', 'toggled') : 'toggleDrivers',
            ('CustomdriversAddButton', 'clicked') : 'addDriver',
            ('CustomdriversRemoveButton', 'clicked') : 'removeDriver',
          })

        if userchoices.getDriversLoaded():
            self.xml.get_widget('CustomdriversVBox').set_sensitive(False)

        self.view = self.xml.get_widget('CustomdriversTreeView')
        self.scrolled = self.xml.get_widget('CustomdriversScrolledWindow')

        self.addDrivers = AddDrivers(self)

        _setupAddDriversView(self.view)

        # build up self.driverList in case the user has gone back
        # from the screen and re-entered it
        self.buildDriverList()

        # unmount the cdrom so the user can eject it manually
        util.umount(MEDIA_DEVICE_MOUNT_POINT)
コード例 #11
0
def test_hello(tmpdir, name, options):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', name),
                '-f', mnt_dir ] + options
    if name == 'hello_ll':
        # supports single-threading only
        cmdline.append('-s')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        assert os.listdir(mnt_dir) == ['hello']
        filename = pjoin(mnt_dir, 'hello')
        with open(filename, 'r') as fh:
            assert fh.read() == 'Hello World!\n'
        with pytest.raises(IOError) as exc_info:
            open(filename, 'r+')
        assert exc_info.value.errno == errno.EACCES
        with pytest.raises(IOError) as exc_info:
            open(filename + 'does-not-exist', 'r+')
        assert exc_info.value.errno == errno.ENOENT
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #12
0
ファイル: test_examples.py プロジェクト: johanalenius/main
def test_passthroughfs(tmpdir):
    mnt_dir = str(tmpdir.mkdir("mnt"))
    src_dir = str(tmpdir.mkdir("src"))
    cmdline = [sys.executable, os.path.join(basename, "examples", "passthroughfs.py"), src_dir, mnt_dir]
    mount_process = subprocess.Popen(cmdline, stdin=subprocess.DEVNULL, universal_newlines=True)
    try:
        wait_for_mount(mount_process, mnt_dir)
        tst_write(mnt_dir)
        tst_mkdir(mnt_dir)
        tst_symlink(mnt_dir)
        tst_mknod(mnt_dir)
        if os.getuid() == 0:
            tst_chown(mnt_dir)
        # Underlying fs may not have full nanosecond resolution
        tst_utimens(mnt_dir, ns_tol=1000)
        tst_link(mnt_dir)
        tst_readdir(mnt_dir)
        tst_statvfs(mnt_dir)
        tst_truncate(mnt_dir)
        tst_passthrough(src_dir, mnt_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #13
0
ファイル: test_ctests.py プロジェクト: everbase/libfuse
def test_notify1(tmpdir, name, notify):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', name),
                '-f', '--update-interval=1', mnt_dir ]
    if not notify:
        cmdline.append('--no-notify')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        filename = pjoin(mnt_dir, 'current_time')
        with open(filename, 'r') as fh:
            read1 = fh.read()
        safe_sleep(2)
        with open(filename, 'r') as fh:
            read2 = fh.read()
        if notify:
            assert read1 != read2
        else:
            assert read1 == read2
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #14
0
ファイル: test_examples.py プロジェクト: CameronOC/libfuse
def test_fusexmp_fh(tmpdir, name):
    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = [os.path.join(basename, 'example', name),
                '-f', '-o' , 'use_ino,readdir_ino,kernel_cache',
                mnt_dir ]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        work_dir = os.path.join(mnt_dir, src_dir)
        tst_write(work_dir)
        tst_mkdir(work_dir)
        tst_symlink(work_dir)
        tst_mknod(work_dir)
        if os.getuid() == 0:
            tst_chown(work_dir)
        # Underlying fs may not have full nanosecond resolution
        tst_utimens(work_dir, ns_tol=1000)
        tst_link(work_dir)
        tst_readdir(work_dir)
        tst_statvfs(work_dir)
        tst_truncate_path(work_dir)
        tst_truncate_fd(work_dir)
        tst_unlink(work_dir)
        tst_passthrough(src_dir, work_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #15
0
ファイル: test_examples.py プロジェクト: everbase/libfuse
def test_ioctl(tmpdir):
    progname = pjoin(basename, 'example', 'ioctl')
    if not os.path.exists(progname):
        pytest.skip('%s not built' % os.path.basename(progname))
    
    mnt_dir = str(tmpdir)
    testfile = pjoin(mnt_dir, 'fioc')
    cmdline = base_cmdline + [progname, '-f', mnt_dir ]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)

        cmdline = base_cmdline + \
                  [ pjoin(basename, 'example', 'ioctl_client'),
                    testfile ]
        assert subprocess.check_output(cmdline) == b'0\n'
        with open(testfile, 'wb') as fh:
            fh.write(b'foobar')
        assert subprocess.check_output(cmdline) == b'6\n'
        subprocess.check_call(cmdline + [ '3' ])
        with open(testfile, 'rb') as fh:
            assert fh.read()== b'foo'
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #16
0
def test_notify_file_size(tmpdir, notify, output_checker):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', 'invalidate_path'),
                '-f', '--update-interval=1', mnt_dir ]
    if not notify:
        cmdline.append('--no-notify')
    mount_process = subprocess.Popen(cmdline,
                                     stdout=output_checker.fd,
                                     stderr=output_checker.fd)
    try:
        wait_for_mount(mount_process, mnt_dir)
        filename = pjoin(mnt_dir, 'growing')
        size = os.path.getsize(filename)
        safe_sleep(2)
        new_size = os.path.getsize(filename)
        if notify:
            assert new_size > size
        else:
            assert new_size == size
    except:
        cleanup(mount_process, mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #17
0
ファイル: usbmedia.py プロジェクト: vmware/weasel
def findUSBMedia(showAll=False):
    """Scan attached USB devices for installation media.

    If showAll is True, all CD devices are returned even if they do not contain
    any installation media.
    """
    
    diskSet = devices.DiskSet(forceReprobe=True)

    retval = []
    
    util.umount(USB_MEDIA_PATH)
    for disk in diskSet.values():
        if disk.driverName != devices.DiskDev.DRIVER_USB_STORAGE:
            log.debug("skipping non-usb device -- %s" % disk.name)
            continue

        diskMedia = []
        for part in disk.partitions:
            if not part.consoleDevicePath:
                continue
            
            diskMedia += _tryDevice(disk, part)

        if not diskMedia and showAll:
            # No installation media was found on the device, but the caller
            # wants the list of potential media devices, so add that in.
            diskMedia = [media.MediaDescriptor(disk.name)]
            
        retval += diskMedia

    return retval
コード例 #18
0
ファイル: test_fs.py プロジェクト: cbenhagen/python-llfuse
def testfs(tmpdir):

    # We can't use forkserver because we have to make sure
    # that the server inherits the per-test stdout/stderr file
    # descriptors.
    if hasattr(multiprocessing, 'get_context'):
        mp = multiprocessing.get_context('fork')
    else:
        # Older versions only support *fork* anyway
        mp = multiprocessing
    if threading.active_count() != 1:
        raise RuntimeError("Multi-threaded test running is not supported")

    mnt_dir = str(tmpdir)
    with mp.Manager() as mgr:
        cross_process = mgr.Namespace()
        mount_process = mp.Process(target=run_fs,
                                   args=(mnt_dir, cross_process))

        mount_process.start()
        try:
            wait_for_mount(mount_process, mnt_dir)
            yield (mnt_dir, cross_process)
        except:
            cleanup(mnt_dir)
            raise
        else:
            umount(mount_process, mnt_dir)
コード例 #19
0
def test_passthroughfs(tmpdir):
    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))
    cmdline = [sys.executable,
               os.path.join(basename, 'examples', 'passthroughfs.py'),
               src_dir, mnt_dir ]
    mount_process = subprocess.Popen(cmdline, stdin=subprocess.DEVNULL,
                                     universal_newlines=True)
    try:
        wait_for_mount(mount_process, mnt_dir)
        tst_write(mnt_dir)
        tst_mkdir(mnt_dir)
        tst_symlink(mnt_dir)
        tst_mknod(mnt_dir)
        if os.getuid() == 0:
            tst_chown(mnt_dir)
        tst_chmod(mnt_dir)
        # Underlying fs may not have full nanosecond resolution
        tst_utimens(mnt_dir, ns_tol=1000)
        tst_rounding(mnt_dir)
        tst_link(mnt_dir)
        tst_readdir(mnt_dir)
        tst_statvfs(mnt_dir)
        tst_truncate_path(mnt_dir)
        tst_truncate_fd(mnt_dir)
        tst_unlink(mnt_dir)
        tst_passthrough(src_dir, mnt_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #20
0
ファイル: usbmedia.py プロジェクト: vmware/weasel
def _tryDevice(disk, part):
    devicePath = part.consoleDevicePath
    
    log.info("looking for installation data on %s" % devicePath)

    # Either the USB storage is the media itself or it might contain an ISO file
    # that is the installation media.
    usbDesc = media.MediaDescriptor(disk.name, devicePath, part.getFsTypeName())
    if usbDesc.probeForPackages():
        log.info("  found installation media...")
        return [usbDesc]
    
    # Be explicit about fsTypeName since long file names work if we mount it as
    # "vfat", but not when the auto-detection thinks it's "msdos".
    if util.mount(devicePath,
                  USB_MEDIA_PATH,
                  fsTypeName=part.getFsTypeName()) != 0:
        return []

    retval = []
    for iso in glob.glob(os.path.join(USB_MEDIA_PATH, "*.iso")):
        isoDesc = media.MediaDescriptor(
            disk.name,
            devicePath, part.getFsTypeName(),
            os.path.basename(iso))
        if isoDesc.probeForPackages():
            log.info("  found iso, %s, with installation media..." % iso)
            retval.append(isoDesc)

    util.umount(USB_MEDIA_PATH)
    
    return retval
コード例 #21
0
ファイル: test_examples.py プロジェクト: everbase/libfuse
def test_hello(tmpdir, name, options):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', name),
                '-f', mnt_dir ] + options
    if name == 'hello_ll':
        # supports single-threading only
        cmdline.append('-s')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        assert os.listdir(mnt_dir) == [ 'hello' ]
        filename = pjoin(mnt_dir, 'hello')
        with open(filename, 'r') as fh:
            assert fh.read() == 'Hello World!\n'
        with pytest.raises(IOError) as exc_info:
            open(filename, 'r+')
        assert exc_info.value.errno == errno.EACCES
        with pytest.raises(IOError) as exc_info:
            open(filename + 'does-not-exist', 'r+')
        assert exc_info.value.errno == errno.ENOENT
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #22
0
ファイル: test_examples.py プロジェクト: everbase/libfuse
def test_notify_inval_entry(tmpdir, notify):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', 'notify_inval_entry'),
                '-f', '--update-interval=1',
                '--timeout=5', mnt_dir ]
    if not notify:
        cmdline.append('--no-notify')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        fname = pjoin(mnt_dir, os.listdir(mnt_dir)[0])
        try:
            os.stat(fname)
        except FileNotFoundError:
            # We may have hit a race condition and issued
            # readdir just before the name changed
            fname = pjoin(mnt_dir, os.listdir(mnt_dir)[0])
            os.stat(fname)

        safe_sleep(2)
        if not notify:
            os.stat(fname)
            safe_sleep(5)
        with pytest.raises(FileNotFoundError):
            os.stat(fname)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #23
0
def test_ioctl(tmpdir, output_checker):
    progname = pjoin(basename, 'example', 'ioctl')
    if not os.path.exists(progname):
        pytest.skip('%s not built' % os.path.basename(progname))

    mnt_dir = str(tmpdir)
    testfile = pjoin(mnt_dir, 'fioc')
    cmdline = base_cmdline + [progname, '-f', mnt_dir]
    mount_process = subprocess.Popen(cmdline,
                                     stdout=output_checker.fd,
                                     stderr=output_checker.fd)
    try:
        wait_for_mount(mount_process, mnt_dir)

        cmdline = base_cmdline + \
                  [ pjoin(basename, 'example', 'ioctl_client'),
                    testfile ]
        assert subprocess.check_output(cmdline) == b'0\n'
        with open(testfile, 'wb') as fh:
            fh.write(b'foobar')
        assert subprocess.check_output(cmdline) == b'6\n'
        subprocess.check_call(cmdline + ['3'])
        with open(testfile, 'rb') as fh:
            assert fh.read() == b'foo'
    except:
        cleanup(mount_process, mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #24
0
def test_tmpfs(tmpdir):
    mnt_dir = str(tmpdir)
    cmdline = [sys.executable,
               os.path.join(basename, 'examples', 'tmpfs.py'),
               mnt_dir ]
    mount_process = subprocess.Popen(cmdline, stdin=subprocess.DEVNULL,
                                     universal_newlines=True)
    try:
        wait_for_mount(mount_process, mnt_dir)
        tst_write(mnt_dir)
        tst_mkdir(mnt_dir)
        tst_symlink(mnt_dir)
        tst_mknod(mnt_dir)
        tst_chown(mnt_dir)
        tst_chmod(mnt_dir)
        tst_utimens(mnt_dir)
        tst_rounding(mnt_dir)
        tst_link(mnt_dir)
        tst_readdir(mnt_dir)
        tst_statvfs(mnt_dir)
        tst_truncate_path(mnt_dir)
        tst_truncate_fd(mnt_dir)
        tst_unlink(mnt_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #25
0
ファイル: test_fs.py プロジェクト: mkhon/python-llfuse
def testfs(tmpdir):

    # We can't use forkserver or spawn because of
    # https://github.com/pytest-dev/pytest/issues/958.
    if hasattr(multiprocessing, 'get_context'):
        mp = multiprocessing.get_context('fork')
    else:
        # Older versions only support *fork* anyway
        mp = multiprocessing
    if threading.active_count() != 1:
        raise RuntimeError("Multi-threaded test running is not supported")

    mnt_dir = str(tmpdir)
    with mp.Manager() as mgr:
        cross_process = mgr.Namespace()
        mount_process = mp.Process(target=run_fs,
                                   args=(mnt_dir, cross_process))

        mount_process.start()
        try:
            wait_for_mount(mount_process, mnt_dir)
            yield (mnt_dir, cross_process)
        except:
            cleanup(mnt_dir)
            raise
        else:
            umount(mount_process, mnt_dir)
コード例 #26
0
ファイル: test_examples.py プロジェクト: Rprabudeva/pyfuse3-1
def test_hello(tmpdir, filename):
    mnt_dir = str(tmpdir)
    cmdline = [
        sys.executable,
        os.path.join(basename, 'examples', filename), mnt_dir
    ]
    mount_process = subprocess.Popen(cmdline,
                                     stdin=subprocess.DEVNULL,
                                     universal_newlines=True)
    try:
        wait_for_mount(mount_process, mnt_dir)
        assert os.listdir(mnt_dir) == ['message']
        filename = os.path.join(mnt_dir, 'message')
        with open(filename, 'r') as fh:
            assert fh.read() == 'hello world\n'
        with pytest.raises(IOError) as exc_info:
            open(filename, 'r+')
        assert exc_info.value.errno == errno.EACCES
        with pytest.raises(IOError) as exc_info:
            open(filename + 'does-not-exist', 'r+')
        assert exc_info.value.errno == errno.ENOENT
    except:
        cleanup(mount_process, mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #27
0
ファイル: rom_drives.py プロジェクト: 1147279/SoftwareProject
 def umount(self):
     """
     Mount the media
     """
     _debug_('Unmounting disc in drive %s' % self.drivename, 2)
     util.umount(self.mountdir)
     return
コード例 #28
0
def test_notify1(tmpdir, name, notify):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', name),
                '-f', '--update-interval=1', mnt_dir ]
    if not notify:
        cmdline.append('--no-notify')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        filename = pjoin(mnt_dir, 'current_time')
        with open(filename, 'r') as fh:
            read1 = fh.read()
        safe_sleep(2)
        with open(filename, 'r') as fh:
            read2 = fh.read()
        if notify:
            assert read1 != read2
        else:
            assert read1 == read2
    except:
        cleanup(mount_process, mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #29
0
 def finish(self):
     if self.start_count == 0:
         return
     self.start_count -= 1
     if self.start_count == 0:
         util.umount(self.location)
         os.rmdir(self.location)
         self.location = None
コード例 #30
0
ファイル: source.py プロジェクト: jsbronder/inhibitor
 def remove(self):
     if self.mount:
         util.umount(self.mount, self.istate.mount_points)
     elif not self.keep:
         for f in self.installed:
             d = os.path.dirname(f)
             os.unlink(f)
             if len( os.listdir(d) ) == 0:
                 os.rmdir(d)
コード例 #31
0
ファイル: media.py プロジェクト: vmware-archive/weasel
    def umount(self):
        if not self.isMounted:
            return
        
        util.umount(MEDIA_DEVICE_MOUNT_POINT)
        
        if self.partPath:
            util.umount(MEDIA_PATH)

        self.isMounted = False
コード例 #32
0
def test_passthrough(tmpdir, name, debug, capfd):

    # Avoid false positives from libfuse debug messages
    if debug:
        capfd.register_output(r'^   unique: [0-9]+, error: -[0-9]+ .+$',
                              count=0)

    # test_syscalls prints "No error" under FreeBSD
    capfd.register_output(r"^ \d\d \[[^\]]+ message: 'No error: 0'\]", count=0)

    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', name),
                '-f', mnt_dir ]
    if debug:
        cmdline.append('-d')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        work_dir = mnt_dir + src_dir

        tst_statvfs(work_dir)
        tst_readdir(src_dir, work_dir)
        tst_open_read(src_dir, work_dir)
        tst_open_write(src_dir, work_dir)
        tst_create(work_dir)
        tst_passthrough(src_dir, work_dir)
        tst_append(src_dir, work_dir)
        tst_seek(src_dir, work_dir)
        tst_mkdir(work_dir)
        tst_rmdir(src_dir, work_dir)
        tst_unlink(src_dir, work_dir)
        tst_symlink(work_dir)
        if os.getuid() == 0:
            tst_chown(work_dir)

        # Underlying fs may not have full nanosecond resolution
        tst_utimens(work_dir, ns_tol=1000)

        tst_link(work_dir)
        tst_truncate_path(work_dir)
        tst_truncate_fd(work_dir)
        tst_open_unlink(work_dir)

        subprocess.check_call([
            os.path.join(basename, 'test', 'test_syscalls'), work_dir,
            ':' + src_dir
        ])
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #33
0
ファイル: test_examples.py プロジェクト: everbase/libfuse
def test_passthrough(tmpdir, name, debug, capfd):
    
    # Avoid false positives from libfuse debug messages
    if debug:
        capfd.register_output(r'^   unique: [0-9]+, error: -[0-9]+ .+$',
                              count=0)

    # test_syscalls prints "No error" under FreeBSD
    capfd.register_output(r"^ \d\d \[[^\]]+ message: 'No error: 0'\]",
                          count=0)

    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', name),
                '-f', mnt_dir ]
    if debug:
        cmdline.append('-d')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        work_dir = mnt_dir + src_dir

        tst_statvfs(work_dir)
        tst_readdir(src_dir, work_dir)
        tst_open_read(src_dir, work_dir)
        tst_open_write(src_dir, work_dir)
        tst_create(work_dir)
        tst_passthrough(src_dir, work_dir)
        tst_append(src_dir, work_dir)
        tst_seek(src_dir, work_dir)
        tst_mkdir(work_dir)
        tst_rmdir(src_dir, work_dir)
        tst_unlink(src_dir, work_dir)
        tst_symlink(work_dir)
        if os.getuid() == 0:
            tst_chown(work_dir)

        # Underlying fs may not have full nanosecond resolution
        tst_utimens(work_dir, ns_tol=1000)

        tst_link(work_dir)
        tst_truncate_path(work_dir)
        tst_truncate_fd(work_dir)
        tst_open_unlink(work_dir)
        
        subprocess.check_call([ os.path.join(basename, 'test', 'test_syscalls'),
                                work_dir, ':' + src_dir ])
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #34
0
ファイル: stage.py プロジェクト: jsbronder/inhibitor
    def remove_sources(self):
        for src in [x for x in self.sources if (x.keep and not x.mountable)]:
            # Previous actions may have overwritten the source, so
            # it needs to be reinstalled one last time.
            src.install(root=self.target_root)

        for src in self.sources:
            src.remove()
        for m in ("proc", "sys", "devpts", "dev"):
            util.umount(self.aux_mounts[m], self.istate.mount_points)
        for m in ("resolv.conf", "hosts"):
            self.aux_sources[m].remove()
コード例 #35
0
def test_passthrough_hp(tmpdir, cache):
    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', 'passthrough_hp'),
                src_dir, mnt_dir ]

    if not cache:
        cmdline.append('--nocache')

    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)

        tst_statvfs(mnt_dir)
        tst_readdir(src_dir, mnt_dir)
        tst_readdir_big(src_dir, mnt_dir)
        tst_open_read(src_dir, mnt_dir)
        tst_open_write(src_dir, mnt_dir)
        tst_create(mnt_dir)
        tst_passthrough(src_dir, mnt_dir)
        tst_append(src_dir, mnt_dir)
        tst_seek(src_dir, mnt_dir)
        tst_mkdir(mnt_dir)
        tst_rmdir(src_dir, mnt_dir)
        tst_unlink(src_dir, mnt_dir)
        tst_symlink(mnt_dir)
        if os.getuid() == 0:
            tst_chown(mnt_dir)

        # Underlying fs may not have full nanosecond resolution
        tst_utimens(mnt_dir, ns_tol=1000)

        tst_link(mnt_dir)
        tst_truncate_path(mnt_dir)
        tst_truncate_fd(mnt_dir)
        tst_open_unlink(mnt_dir)

        # test_syscalls assumes that changes in source directory
        # will be reflected immediately in mountpoint, so we
        # can't use it.
        if not cache:
            syscall_test_cmd = [
                os.path.join(basename, 'test', 'test_syscalls'), mnt_dir,
                ':' + src_dir
            ]
            subprocess.check_call(syscall_test_cmd)
    except:
        cleanup(mount_process, mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #36
0
 def unmount(self):
     if self.mountedServer:
         # Use the nfs specific umount, since the busybox one does not work
         # well with unreachable nfs servers.
         nfsMountPoint = self.mountpoint
         if self.mountedRoot.endswith('.iso'):
             util.umount(self.mountpoint)
             nfsMountPoint = "%s-isosrc" % self.mountpoint
         command = '/sbin/umount.nfs'
         argv = [command, nfsMountPoint, '-f']
         execWithLog(command, argv, level=logging.DEBUG)
     self.mountedServer = None
     self.mountedRoot = None
コード例 #37
0
def tidyActionUnmount():
    requests = allUserPartitionRequests()
    requests.sort(sortByMountPoint=True)
    requests.reverse()

    for request in requests:
        if not request.mountPoint:
            continue

        mountPoint = os.path.normpath(consts.HOST_ROOT + request.mountPoint)
        if os.path.exists(mountPoint):
            log.debug("Unmounting %s" % (mountPoint))
            util.umount(mountPoint)
コード例 #38
0
ファイル: remote_files.py プロジェクト: vmware/weasel
 def unmount(self):
     if self.mountedServer:
         # Use the nfs specific umount, since the busybox one does not work
         # well with unreachable nfs servers.
         nfsMountPoint = self.mountpoint
         if self.mountedRoot.endswith('.iso'):
             util.umount(self.mountpoint)
             nfsMountPoint = "%s-isosrc" % self.mountpoint
         command = '/sbin/umount.nfs'
         argv = [command, nfsMountPoint, '-f']
         execWithLog(command, argv, level=logging.DEBUG)
     self.mountedServer = None
     self.mountedRoot = None
コード例 #39
0
def test_fsel(tmpdir):
    mnt_dir = str(tmpdir)
    cmdline = [os.path.join(basename, 'example', 'fsel'), '-f', mnt_dir]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        cmdline = [os.path.join(basename, 'example', 'fselclient')]
        subprocess.check_call(cmdline, cwd=mnt_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #40
0
ファイル: test_examples.py プロジェクト: CameronOC/libfuse
def test_fsel(tmpdir):
    mnt_dir = str(tmpdir)
    cmdline = [os.path.join(basename, 'example', 'fsel'),
               '-f', mnt_dir ]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        cmdline = [ os.path.join(basename, 'example', 'fselclient') ]
        subprocess.check_call(cmdline, cwd=mnt_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #41
0
def setup_unreliablefs(tmpdir):
    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    options = "-basedir={}".format(src_dir)
    cmdline = base_cmdline + [
        pjoin(basename, 'build/unreliablefs'), mnt_dir, options
    ]
    mount_process = subprocess.Popen(cmdline)
    wait_for_mount(mount_process, mnt_dir)

    yield mnt_dir, src_dir

    umount(mount_process, mnt_dir)
    cleanup(mount_process, mnt_dir)
コード例 #42
0
ファイル: test_examples.py プロジェクト: clibs/fuse-linux
def test_poll(tmpdir, output_checker):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + [pjoin(basename, 'example', 'poll'),
               '-f', mnt_dir ]
    mount_process = subprocess.Popen(cmdline, stdout=output_checker.fd,
                                     stderr=output_checker.fd)
    try:
        wait_for_mount(mount_process, mnt_dir)
        cmdline = base_cmdline + \
                  [ pjoin(basename, 'example', 'poll_client') ]
        subprocess.check_call(cmdline, cwd=mnt_dir)
    except:
        cleanup(mount_process, mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #43
0
def umountEject(uMountPoint):
    """Attempt to reliably unmount the media and eject it.  This can
    be kludgey.  umount on some systems doesn't free up the resource
    that eject thinks has to be free.
    """
    # TODO AND NOTES:
    # 1. Deliberately inserting the wrong CD can lead to duplicate mounts,
    #    and later umount trouble.  Workaround: select a separate console,
    #    and manually umount.  Need to bullet-proof this better.
    # 2. umount immediately followed by eject has been known to failed
    #    on certain other Busybox/uClibc/2.4kernel systems.  Injecting a sleep
    #    works around the problem.
    import time
    for trial in (1, 2, 3):
        if uMountPoint:  # guard against NoneType, ''
            status = util.umount(uMountPoint)
            if status == 0:  # success
                break
            else:
                args = ["/usr/bin/umount", "-f", uMountPoint]
                status = util.execWithLog(args[0], args)
                log.warn('Forced umount of %s: %d' % (uMountPoint, status))
            time.sleep(1)
            log.warn('customdrivers_ui umount attempt %d failed' % trial)

    status = cdutil.ejectCdrom()
    return status
コード例 #44
0
ファイル: test_fs.py プロジェクト: savitha18/pyfuse3
def testfs(tmpdir):
    mnt_dir = str(tmpdir)
    mp = get_mp()
    with mp.Manager() as mgr:
        cross_process = mgr.Namespace()
        mount_process = mp.Process(target=run_fs,
                                   args=(mnt_dir, cross_process))

        mount_process.start()
        try:
            wait_for_mount(mount_process, mnt_dir)
            yield (mnt_dir, cross_process)
        except:
            cleanup(mnt_process, mnt_dir)
            raise
        else:
            umount(mount_process, mnt_dir)
コード例 #45
0
def _usbOption(match):
    '''Handle the "ks=usb" and "ks=usb:<path>" option.'''

    try:
        ksFile = match.group(1)
    except IndexError:
        ksFile = "ks.cfg"

    firstTime = True
    while True:
        if not firstTime:
            # XXX Maybe we should just stop retrying after awhile?
            log.info("Insert a USB storage device that contains '%s' "
                     "file to perform a scripted install..." % ksFile)
            util.rawInputCountdown("\rrescanning in %2d second(s), "
                                   "press <enter> to rescan immediately", 10)
        firstTime = False

        diskSet = devices.DiskSet(forceReprobe=True)

        usbDisks = [disk for disk in diskSet.values()
                    if disk.driverName == devices.DiskDev.DRIVER_USB_STORAGE]

        if not usbDisks:
            log.info("") # XXX just for spacing
            log.warn("No USB storage found.")
            continue

        kickstartPath = os.path.join(USB_MOUNT_PATH, ksFile.lstrip('/'))

        if not os.path.exists(USB_MOUNT_PATH):
            os.makedirs(USB_MOUNT_PATH)

        for disk in usbDisks:
            for part in disk.partitions:
                if part.partitionId == -1:
                    continue

                if (part.getFsTypeName() not in ("ext2", "ext3", "vfat")):
                    # Don't try mounting partitions with filesystems that aren't
                    # likely to be on a usb key.
                    continue

                if util.mount(part.consoleDevicePath,
                              USB_MOUNT_PATH,
                              fsTypeName=part.getFsTypeName()):
                    log.warn("Unable to mount '%s'" % part.consoleDevicePath)
                    continue

                if os.path.exists(kickstartPath):
                    userchoices.addDriveUse(disk.name, 'kickstart')
                    return [('-s', kickstartPath)]

                if util.umount(USB_MOUNT_PATH):
                    failWithLog("Unable to umount '%s'" % USB_MOUNT_PATH)

        log.info("")
        log.warn("%s was not found on any attached USB storage." % ksFile)
コード例 #46
0
def _ksFileCdromOption(match):
    path = match.group(1)

    if not os.path.exists(CDROM_MOUNT_PATH):
        os.makedirs(CDROM_MOUNT_PATH)

    for cdPath in cdutil.cdromDevicePaths():
        if util.mount(cdPath, CDROM_MOUNT_PATH):
            log.warn("cannot mount cd-rom in %s" % cdPath)
            continue

        ksPath = os.path.join(CDROM_MOUNT_PATH, path.lstrip('/'))
        if os.path.exists(ksPath):
            return [('-s', ksPath)]

        util.umount(CDROM_MOUNT_PATH)

    failWithLog("cannot find kickstart file on cd-rom with path -- %s" % path)
コード例 #47
0
ファイル: test_fuse.py プロジェクト: CameronOC/libfuse
def test_fuse(tmpdir):
    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = [ os.path.join(basename, 'example', 'fusexmp_fh'),
                '-f', '-o' , 'use_ino,readdir_ino,kernel_cache',
                mnt_dir ]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        cmdline = [ os.path.join(basename, 'test', 'test'),
                    os.path.join(mnt_dir, src_dir),
                    ':' + src_dir ]
        subprocess.check_call(cmdline)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #48
0
ファイル: test_examples.py プロジェクト: johanalenius/main
def test_lltest(tmpdir):
    mnt_dir = str(tmpdir)
    cmdline = [sys.executable, os.path.join(basename, "examples", "lltest.py"), mnt_dir]
    mount_process = subprocess.Popen(cmdline, stdin=subprocess.DEVNULL, universal_newlines=True)
    try:
        wait_for_mount(mount_process, mnt_dir)
        assert os.listdir(mnt_dir) == ["message"]
        filename = os.path.join(mnt_dir, "message")
        with open(filename, "r") as fh:
            assert fh.read() == "hello world\n"
        with pytest.raises(IOError) as exc_info:
            open(filename, "r+")
        assert exc_info.value.errno == errno.EPERM
        with pytest.raises(IOError) as exc_info:
            open(filename + "does-not-exist", "r+")
        assert exc_info.value.errno == errno.ENOENT
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #49
0
ファイル: test_examples.py プロジェクト: everbase/libfuse
def test_passthrough_ll(tmpdir, writeback, debug, capfd):
    
    progname = pjoin(basename, 'example', 'passthrough_ll')
    if not os.path.exists(progname):
        pytest.skip('%s not built' % os.path.basename(progname))
    
    # Avoid false positives from libfuse debug messages
    if debug:
        capfd.register_output(r'^   unique: [0-9]+, error: -[0-9]+ .+$',
                              count=0)

    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = base_cmdline + [ progname, '-f', mnt_dir ]
    if debug:
        cmdline.append('-d')

    if writeback:
        cmdline.append('-o')
        cmdline.append('writeback')
        
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        work_dir = mnt_dir + src_dir

        tst_statvfs(work_dir)
        tst_readdir(src_dir, work_dir)
        tst_open_read(src_dir, work_dir)
        tst_open_write(src_dir, work_dir)
        tst_create(work_dir)
        tst_passthrough(src_dir, work_dir)
        tst_append(src_dir, work_dir)
        tst_seek(src_dir, work_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #50
0
ファイル: bugtool.py プロジェクト: xtha/pxe
def bugtool(inst, dest_url):
    try:
        inst.mount_root(ro = False)

        util.bindMount('/dev', os.path.join(inst.root_fs.mount_point, 'dev'))
        util.bindMount('/proc', os.path.join(inst.root_fs.mount_point, 'proc'))
        util.bindMount('/sys', os.path.join(inst.root_fs.mount_point, 'sys'))

        os.environ['XEN_RT'] = '1'
        os.environ['XENRT_BUGTOOL_BASENAME'] = 'offline-bugtool'
        util.runCmd2(['chroot', inst.root_fs.mount_point, '/usr/sbin/xen-bugtool', '-y', '--unlimited'])
        out_fname = os.path.join(inst.root_fs.mount_point, 'var/opt/xen/bug-report/offline-bugtool.tar.bz2')

        util.umount(os.path.join(inst.root_fs.mount_point, 'sys'))
        util.umount(os.path.join(inst.root_fs.mount_point, 'proc'))
        util.umount(os.path.join(inst.root_fs.mount_point, 'dev'))

        xcp.logger.log("Saving to " + dest_url)
        a = xcp.accessor.createAccessor(dest_url, False)
        a.start()
        inh = open(out_fname)
        a.writeFile(inh, 'offline-bugtool.tar.bz2')
        inh.close()
        a.finish()

        os.remove(out_fname)
    finally:
        inst.unmount_root()
コード例 #51
0
ファイル: test_examples.py プロジェクト: CameronOC/libfuse
def test_hello(tmpdir, name):
    mnt_dir = str(tmpdir)
    cmdline = [os.path.join(basename, 'example', name),
               '-f', mnt_dir ]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        assert os.listdir(mnt_dir) == [ 'hello' ]
        filename = os.path.join(mnt_dir, 'hello')
        with open(filename, 'r') as fh:
            assert fh.read() == 'Hello World!\n'
        with pytest.raises(IOError) as exc_info:
            open(filename, 'r+')
        assert exc_info.value.errno == errno.EACCES
        with pytest.raises(IOError) as exc_info:
            open(filename + 'does-not-exist', 'r+')
        assert exc_info.value.errno == errno.ENOENT
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #52
0
ファイル: test_examples.py プロジェクト: everbase/libfuse
def test_null(tmpdir):
    progname = pjoin(basename, 'example', 'null')
    if not os.path.exists(progname):
        pytest.skip('%s not built' % os.path.basename(progname))
    
    mnt_file = str(tmpdir) + '/file'
    with open(mnt_file, 'w') as fh:
        fh.write('dummy')
    cmdline = base_cmdline + [ progname, '-f', mnt_file ]
    mount_process = subprocess.Popen(cmdline)
    def test_fn(name):
        return os.stat(name).st_size > 4000
    try:
        wait_for_mount(mount_process, mnt_file, test_fn)
        with open(mnt_file, 'rb') as fh:
            assert fh.read(382) == b'\0' * 382
        with open(mnt_file, 'wb') as fh:
            fh.write(b'whatever')
    except:
        cleanup(mnt_file)
        raise
    else:
        umount(mount_process, mnt_file)
コード例 #53
0
ファイル: test_ctests.py プロジェクト: everbase/libfuse
def test_notify_file_size(tmpdir, notify):
    mnt_dir = str(tmpdir)
    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', 'invalidate_path'),
                '-f', '--update-interval=1', mnt_dir ]
    if not notify:
        cmdline.append('--no-notify')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        filename = pjoin(mnt_dir, 'growing')
        size = os.path.getsize(filename)
        safe_sleep(2)
        new_size = os.path.getsize(filename)
        if notify:
            assert new_size > size
        else:
            assert new_size == size
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #54
0
ファイル: test_examples.py プロジェクト: CameronOC/libfuse
def test_fioc(tmpdir):
    mnt_dir = str(tmpdir)
    testfile = os.path.join(mnt_dir, 'fioc')
    cmdline = [os.path.join(basename, 'example', 'fioc'),
               '-f', mnt_dir ]
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)

        base_cmd = [ os.path.join(basename, 'example', 'fioclient'),
                     testfile ]
        assert subprocess.check_output(base_cmd) == b'0\n'
        with open(testfile, 'wb') as fh:
            fh.write(b'foobar')
        assert subprocess.check_output(base_cmd) == b'6\n'
        subprocess.check_call(base_cmd + [ '3' ])
        with open(testfile, 'rb') as fh:
            assert fh.read()== b'foo'
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #55
0
ファイル: test_examples.py プロジェクト: quobert/libfuse
def test_passthrough(tmpdir, name, debug):
    mnt_dir = str(tmpdir.mkdir('mnt'))
    src_dir = str(tmpdir.mkdir('src'))

    cmdline = base_cmdline + \
              [ pjoin(basename, 'example', name),
                '-f', mnt_dir ]
    if debug:
        cmdline.append('-d')
    mount_process = subprocess.Popen(cmdline)
    try:
        wait_for_mount(mount_process, mnt_dir)
        work_dir = pjoin(mnt_dir, src_dir)

        subprocess.check_call([ os.path.join(basename, 'test', 'test'),
                    work_dir, ':' + src_dir ])

        tst_write(work_dir)
        tst_mkdir(work_dir)
        tst_symlink(work_dir)
        tst_mknod(work_dir)
        if os.getuid() == 0:
            tst_chown(work_dir)
        # Underlying fs may not have full nanosecond resolution
        tst_utimens(work_dir, ns_tol=1000)
        tst_link(work_dir)
        tst_readdir(work_dir)
        tst_statvfs(work_dir)
        tst_truncate_path(work_dir)
        tst_truncate_fd(work_dir)
        tst_unlink(work_dir)
        tst_passthrough(src_dir, work_dir)
    except:
        cleanup(mnt_dir)
        raise
    else:
        umount(mount_process, mnt_dir)
コード例 #56
0
ファイル: customdrivers_gui.py プロジェクト: vmware/weasel
    def scanForDriverDisk(self):
        '''Mount the CD-ROM and check to see if it is a driver CD.'''

        self.foundDriverList = []
        driverDict = {}

        xmlFileName = os.path.join(MEDIA_DEVICE_MOUNT_POINT, "drivers.xml")

        util.umount(MEDIA_DEVICE_MOUNT_POINT)
        cdutil.ejectCdrom()
        window = MessageWindow(None, "Insert CD", INSERT_DRIVER_CD_STRING,
                               type="okcancel")

        if window.affirmativeResponse:
            util.mount(CDROM_DEVICE_PATH, MEDIA_DEVICE_MOUNT_POINT)
            if not os.path.exists(xmlFileName):
                raise InvalidDriverCDException(INVALID_DRIVER_CD_STRING)
        else:
            return

        try:
            driverXml = customdrivers.CustomDriversXML(xmlFileName)
        except customdrivers.InvalidVersion, msg:
            raise InvalidDriverCDException(INVALID_VERSION_STRING)
コード例 #57
0
ファイル: customdrivers_gui.py プロジェクト: vmware/weasel
    def importClicked(self, widget, *args):
        store, selected = self.view.get_selection().get_selected_rows()

        if not selected:
            MessageWindow(None, 'Driver Selection Error',
                          'You must select a driver to import.')
            return

        for entry in selected:
            packageName = store[entry[0]][DRIVERMODEL_PACKAGE]

            if _checkForCollision(packageName, self.parent.driverList,
                                  self.parent.driverDict):
                MessageWindow(None, 'Driver Import Error',
                         "Couldn't add the %s package due to a conflict." %
                          packageName)
                continue

            fileName = os.path.join(MEDIA_DEVICE_MOUNT_POINT, packageName)
            assert os.path.exists(fileName)

            targetFileName = \
                os.path.join(customdrivers.DRIVER_DEPOT_DIR,
                             os.path.basename(packageName))


            self.parent.driverList.append(tuple(store[entry[0]]))
            self.parent.updateDriverList()

            shutil.copy(fileName, targetFileName)

            self.xml.get_widget('CustomdriversRemoveButton').set_sensitive(True)

        # leave the CDROM unmounted so the user can eject it manually
        util.umount(MEDIA_DEVICE_MOUNT_POINT)
        self.hide()