Jump to content


Photo

Mount Manager


  • Please log in to reply
67 replies to this topic

#1 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 15 March 2015 - 21:11

version 1.1

-mount device on UUID
-edit fsab

-set/edit label for device

-support MMC(Formuler)
- support internal HDD ет8000/8500/10000


GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Mount Manager #2 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 15 March 2015 - 21:25

@Dimitrij, os.system (and friends eg os.popen) from enigma2 can be really evil :> sometimes you might get error ENOMEM.

It's better to make use resource friendly eConsoleAppContainer (vfork).

Unfortunatelly eConsoleAppContainer designed to run asyncronous and currently you are not getting program return value.

It would be really nice if someone can help with eConsoleAppContainer in order to replace os.system?

Can we have a syncronous eConsoleAppContainer?
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: Mount Manager #3 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 15 March 2015 - 21:45

@Dimitrij,


Another (better) idea is to mount filesystems directly using python (without calling system and external binaries).

There is a python library here for that: https://github.com/o...python-libmount
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: Mount Manager #4 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 16 March 2015 - 08:07

athoik

This is a simple and handy plugin for normal users who do not understand anything in Linux.
I think for  python-libmount that you need a separate plugin.


GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Mount Manager #5 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 16 March 2015 - 11:48

I do not understand what are problems of eConsoleAppContainer mentioned by athoik,agree it is more stable than os.system and more flexible to handle any situation and has advantage to monitor progression of  execution

os.system has advantage on (some situation) that the code execution stopped until command execution finished but this can be accomplished in  eConsoleAppContainer by  enigma.eConsoleAppContainer.appClosed  and returned data handled by enigma.eConsoleAppContainer.dataAvail 



Re: Mount Manager #6 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 16 March 2015 - 13:53

os.system (and friends eg os.popen) do have an error,
but I personally saw it only in one case.


GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Mount Manager #7 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 16 March 2015 - 17:18

Hi,

os.system (and friends) soon or late will cause problems ENOMEM. I've seen them many times (especially on long running enigma2).

Eg last time it was happening on softcam restart! Now it uses eConsoleAppContainer and restart is rock stable.

It would make code run better if you mount from python instead of using os.system(mount), at least it would be less possible to get ENOMEM.

Here is the code:

https://raw.githubusercontent.com/ox-it/python-libmount/master/libmount/mounting.py

import ctypes

_libc = ctypes.cdll.LoadLibrary("libc.so.6")

# Simple wrapper around mount(2) and umount(2).
# Not thoroughly tested, and not very talkative.

class FLAGS:
    def __new__(self):
        raise NotImplementedError("This class is non-instantiable.")

    def flag_bits(count):
        flag = 1
        for i in range(count):
            yield flag
            flag <<= 1
    
    (
        MS_RDONLY,      #  0
        MS_NOSUID,      #  1
        MS_NODEV,       #  2
        MS_NOEXEC,      #  3
        MS_SYNCHRONOUS, #  4
        MS_REMOUNT,     #  5
        MS_MANDLOCK,    #  6
        MS_DIRSYNC,     #  7
        _, _,           # SKIP 8, 9
        MS_NOATIME,     # 10
        MS_NODIRATIME,  # 11
        MS_BIND,        # 12
        MS_MOVE,        # 13
        MS_REC,         # 14
        MS_SILENT,      # 15
        MS_POSIXACL,    # 16
        MS_UNBINDABLE,  # 17
        MS_PRIVATE,     # 18
        MS_SLAVE,       # 19
        MS_SHARED,      # 20
        MS_RELATIME,    # 21
        MS_KERNMOUNT,   # 22
        MS_I_VERSION,   # 23
        MS_STRICTATIME, # 24
        _, _, _, _, _,  # SKIP 25-29
        MS_ACTIVE,      # 30
        MS_NOUSER,      # 31
    ) = flag_bits(32)
    
    del flag_bits, _
    
    MS_MGC_VAL = 0xc0ed0000
    MS_MGC_MSK = 0xffff0000

def mount(source, target, fstype, flags=0, data=None):
    flags = (flags & FLAGS.MS_MGC_MSK) | FLAGS.MS_MGC_VAL
    
    result = _libc.mount(ctypes.c_char_p(source),
                         ctypes.c_char_p(target),
                         ctypes.c_char_p(fstype),
                         flags,
                         ctypes.c_char_p(data) if data is not None else 0)
    
    if result != 0:
        raise OSError(ctypes.get_errno())

def umount(target):
    result = _libc.umount(ctypes.c_char_p(target))

    if result != 0:
        raise OSError(ctypes.get_errno())

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: Mount Manager #8 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 16 March 2015 - 17:49

I do not understand what are problems of eConsoleAppContainer


I think eConsoleAppContainer cannot return exit code of the process. It might be usefully in some cases. Eg checking what error happened.
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: Mount Manager #9 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 16 March 2015 - 18:08

 

I do not understand what are problems of eConsoleAppContainer


I think eConsoleAppContainer cannot return exit code of the process. It might be usefully in some cases. Eg checking what error happened.

 

may be,i used eConsoleAppContainer to run modules usually 





eConsoleAppContainer.execute("python  default.py"))

and report errors during execution of default.py and the nice feature you can cancel the execution while  we cannot with os.system 


Edited by mfaraj57, 16 March 2015 - 18:10.


Re: Mount Manager #10 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 18 March 2015 - 15:08

doesn't appClosed give you the exit code?



Re: Mount Manager #11 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 18 March 2015 - 18:35

Something like this will do?
 
self.container = eConsoleAppContainer()
self.container.appClosed.append(self.runFinished)
self.container.execute("the_program")

def runFinished(self, retval):
    if retval != 0:
        print "the_program exit code:" + str(retval)
    else:
        #continue executing commands...
Using os.system normaly code goes like this:
 
retval = os.system("the_program")
if reval != 0:
    print "the_program exit code:" + str(retval)
else:
    #continue executing commands...

Edited by athoik, 18 March 2015 - 18:36.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: Mount Manager #12 Erik Slagter

  • PLi® Core member
  • 46,969 posts

+542
Excellent

Posted 18 March 2015 - 18:37

Otherwise you could still wait() :D ;)


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: Mount Manager #13 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 20 March 2015 - 08:10

Need help...

-add reset usb device

 

https://gist.github....aef890469f34d51


"""
    Example code for resetting the USB port that a Teensy microcontroller is
    attached to. There are a lot of situations where a Teensy or Arduino can
    end up in a bad state and need resetting, this code is useful for 
"""

import os
import fcntl
import subprocess


# Equivalent of the _IO('U', 20) constant in the linux kernel.
USBDEVFS_RESET = ord('U') << (4*2) | 20


def get_teensy():
    """
        Gets the devfs path to a Teensy microcontroller by scraping the output
        of the lsusb command
        
        The lsusb command outputs a list of USB devices attached to a computer
        in the format:
            Bus 002 Device 009: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial
        The devfs path to these devices is:
            /dev/bus/usb/<busnum>/<devnum>
        So for the above device, it would be:
            /dev/bus/usb/002/009
        This function generates that path.
    """
    proc = subprocess.Popen(['lsusb'], stdout=subprocess.PIPE)
    out = proc.communicate()[0]
    lines = out.split('\n')
    for line in lines:
        if 'Teensyduino' in line:
            parts = line.split()
            bus = parts[1]
            dev = parts[3][:3]
            return '/dev/bus/usb/%s/%s' % (bus, dev)


def send_reset(dev_path):
    """
        Sends the USBDEVFS_RESET IOCTL to a USB device.
        
        dev_path - The devfs path to the USB device (under /dev/bus/usb/)
                   See get_teensy for example of how to obtain this.
    """
    fd = os.open(dev_path, os.O_WRONLY)
    try:
        fcntl.ioctl(fd, USBDEVFS_RESET, 0)
    finally:
        os.close(fd)


def reset_teensy():
    """
        Finds a teensy and reset it.
    """
    send_reset(get_teensy())

Show error for 'fcntl.ioctl(fd, USBDEVFS_RESET, 0)':

OSError: [Errno 25] Inappropriate ioctl for device

Who can help?


Edited by Dimitrij, 20 March 2015 - 09:02.

GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Mount Manager #14 Erik Slagter

  • PLi® Core member
  • 46,969 posts

+542
Excellent

Posted 20 March 2015 - 10:07

Either the Broadcom SoC doesn't implement this or the kernel driver.

 

Resetting the bus is of limited use, by the way, I've been in a similar situation and resetting never worked.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: Mount Manager #15 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 20 March 2015 - 11:39

Either the Broadcom SoC doesn't implement this or the kernel driver.

 

Resetting the bus is of limited use, by the way, I've been in a similar situation and resetting never worked.

Many thanks.

 

So, there is no solution?


GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Mount Manager #16 Erik Slagter

  • PLi® Core member
  • 46,969 posts

+542
Excellent

Posted 20 March 2015 - 15:17

The problem is really the very limited USB implementation on the microcontroller side, a reset won't be noticed often. And indeed, apparently Broadcom doesn't implement it.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: Mount Manager #17 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 21 March 2015 - 08:50

version 1.2

-code optimization

-add reset usb devices(only code,in fact did not work)


Edited by Dimitrij, 21 March 2015 - 09:05.

GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Mount Manager #18 MiLo

  • PLi® Core member
  • 14,055 posts

+298
Excellent

Posted 21 March 2015 - 14:03

Instead of forking a process, you could also just investigate the /sys/bus/usb/ path using nothing but simple Python code to walk paths and look at file content. There's usually a direct link from the sys directory to the device node to send the ioctl to.
Real musicians never die - they just decompose

Re: Mount Manager #19 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 29 March 2015 - 11:08

version 1.3

-improvement fstab editor

-support more than one mount point for the device


Edited by Dimitrij, 29 March 2015 - 11:09.

GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K


Re: Mount Manager #20 Dimitrij

  • PLi® Core member
  • 10,330 posts

+350
Excellent

Posted 5 May 2015 - 18:00

version 1.5

-fixed definition devices sd*[5-9]
-configurable options for skins:
# skin.xml <parameter name="fstabMenuList" value="0,30,600,50,700,30,500,50" />
# skin.xml <alias name="fstabMenuList" font="Regular" size="28" height="50"/>


Edited by Dimitrij, 6 May 2015 - 09:32.

GigaBlue UHD Quad 4K /Lunix3-4K/Duo 4K



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users