Buchempfehlung
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Umfassend, aber leicht verständlich führt dieses Buch in die Programmierung von ATMEL AVR Mikrocontrollern ein. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

fstab

Uploader:MitgliedJoPa
Datum/Zeit:29.06.2014 12:27:43
Hinweis: Dieser Quelltext ist Bestandteil des Projekts Linux Fstab Pfad hinzufügen, zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.
Warnung: Es steht bereits eine neuere Version des Quelltexts zur Verfügung. Die hier vorliegende alte Version könnte Fehler enthalten, die in der neuen Version vielleicht ausgebessert wurden.

'--Version:0.1

optionen=parameter("-o ")
dump=parameter("-d ")
pass=parameter("-p ")

if parameter("--help")="1" then
    print
    print "---------------------------addfstab Version 0.1-------------------------"
    print "addfstap Hilfe Beispiele:"
    print "    ./addfstab /dev/sda1 -o default,compress,ssd -d 1 -p 2"
    print
    print "um die /etc/fstab zu überschreiben"
    print "    ./addfstab /dev/sda1 -newfstab"
    print
    print "um die Zeile zur Datei hinzuzufügen"
    print "    ./addfstab /dev/sda1 -addfstab"
    print: print "Options:"
    print "   -d            dump"
    print "   -p            pass"
    print "   -o            optionen"
    print "   -addfstab         die Partition wird am Ende der Fstab eingetragen"
    print "   -newfstab         die Partition wird in die Fstab eingetragen"
    print "             dabei wird die fstab überschrieben"
    print
    print "für weiter Hilfen siehe fstab"
    print "ohne Parameter wird folgendes als Standart erstellt"
    print "               default           0         1"
    print
    'print "-------------------------------------------------------------------------"
    end
endif


if optionen="" then optionen="default"
if pass="" then pass="1"
if dump="" then dump="0"


shell ("blkid -o device >/tmp/device.tmp")

open "/tmp/device.tmp" for input as #1
    do
        input #1, device

        for i=1 to len(command$)
            if device= mid(command$, i, len(device)) then 'das Laufwerk, Partition welches man hinzufügen möchte finden
                shell ("blkid -o udev " & device & " >/tmp/devicepa.tmp")
                open "/tmp/devicepa.tmp" for input as #2
                    do
                        input #2, devicepa
                        if left(devicepa, 11)= "ID_FS_UUID=" then UUID=right(devicepa, len(devicepa)-11)
                        if left(devicepa, 11)= "ID_FS_TYPE=" then fsTyp=right(devicepa, len(devicepa)-11)
                    loop until eof(2)


                close #2
            endif


        if UUID<>"" and fsTyp<>"" then exit do

        next i
    loop until eof(1)
close #1

print "UUID="& UUID & " /" & "  " & fsTyp & "       "& optionen & "     " & dump &" " & pass

if parameter("-addfstab")="1" or parameter("-newfstab")="1" then
    name "/etc/fstab", "/etc/fstab-old"
    open "/etc/fstab" for output as #4
    open "/etc/fstab-old" for input as #3
        do
            line input #3,fsline
            if parameter("-addfstab")="1" then print #4, fsline
        loop until eof(3)
        print #4, "#"; device
        print #4, "UUID="& UUID & " /" & "  " & fsTyp & "       "& optionen & "     " & dump &" " & pass
    close #3
    close #4
endif





function parameter(x as string) as string
dim i as integer
dim ia as integer
dim ie as integer

do
            i=i+1
            if x = mid(command$, i, len(x)) then
                if x = "--help" then return "1"
                if x = "-addfstab" then return "1"
                if x = "-newfstab" then return "1"

                i=i+1
                ia=i
                do
                    if mid(command$, i+2, 1)="" or mid(command$, i+2, 1)=" " then
                        ie=i
                        return mid(command$,ia+2, ie-ia)
                        exit do
                    endif
                    i=i+1
                loop until i>=len(command$)

            endif
        loop until i>=len(command$) or ie<>0
end function