Ejemplo n.º 1
0
def main(args):
    global FS, SHELL

    target = None
    try:
        matched_files = []
        for target in args.target_filename:
            matched_files.append(File.resolve_to(FS, target, RegularFile))

        for matched_file in matched_files:
            for line in matched_file.readlines():
                print(line, end="")
    except IncorrectFileTypeError:
        print(f"cat: '{target}/': Is a directory.")
        return 1
    except MissingFileError:
        print(f"cat: '{target}': No such file or directory.")
        return 1


if __name__ == "__main__":
    import sys
    from client_backend import shell_context
    FS = FSDatabase('.fs_db_rdbsh')
    ARGV = sys.argv[1:]
    SHELL = shell_context
    exit(main(parse_args()))

if __name__ == "__rdbsh__":
    exit(main(parse_args()))
Ejemplo n.º 2
0
#!/usr/bin/env python3
import pwd

from argparse import ArgumentParser

from os import chdir
from pathlib import PurePath, Path

from client_backend.fs_db_io import FSDatabase
from client_backend.fs_db_file import *
from client_backend.fs_db_users import *

from stat import S_IRWXU, S_IRWXG, S_IRWXO

FS_DB = FSDatabase('.fs_db_rdbsh')
ROOTFS_PATH = Path('setup/rootfs/')

# Should create root user (uid/gid = 0) & nobody user (uid/gid = 99)


def _to_db_path(path):
    try:
        if path.anchor:
            currentPath = Path().resolve()
            path = path.relative_to(currentPath)
        return PurePath("/").joinpath(path)
    except ValueError:
        print(
            f"Warning: Could not locate'{path}' in Relational Database File System Root ({ROOTFS_PATH} by default)"
        )
        return None