<commit_before>package mount

import (
	"flag"
	"os"
	"syscall"
	"strings"
)

var (
	flagSet   = flag.NewFlagSet("mount", flag.PanicOnError)
	typeFlag  = flagSet.String("t", "", "Filesystem type of the mount")
	flagsFlag = flagSet.String("o", "", "Comma-separated list of flags for the mount (ro, noexec, nosuid, nodev, synchronous, remount)")
	helpFlag  = flagSet.Bool("help", false, "Show this help")

	flagMap = map[string]int{
		"ro":          syscall.MS_RDONLY,
		"noexec":      syscall.MS_NOEXEC,
		"nosuid":      syscall.MS_NOSUID,
		"nodev":       syscall.MS_NODEV,
		"synchronous": syscall.MS_SYNCHRONOUS,
		"remount":     syscall.MS_REMOUNT,
	}
)

func Mount(call []string) os.Error {
	e := flagSet.Parse(call[1:])
	if e != nil {
		return e
	}

	if flagSet.NArg() != 2 || *helpFlag {
		println("`mount` [options] <device> <dir>")
		flagSet.PrintDefaults()
		return nil
	}

	flags, e := parseFlags()
	if e != nil {
		return e
	}

	errno := syscall.Mount(flagSet.Arg(0), flagSet.Arg(1), *typeFlag, flags, "")
	if errno != 0 {
		return os.NewError(syscall.Errstr(errno))
	}
	return nil
}

func parseFlags() (int, os.Error) {
	ret := 0
	parts := strings.Split(*flagsFlag, ",")
	for _, part := range parts {
		part = strings.TrimSpace(part)
		val, ok := flagMap[strings.ToLower(part)]
		if !ok {
			return 0, os.NewError("Invalid flag \"" + part + "\"")
		}
		ret |= val
	}
	return ret, nil
}
<commit_msg>Mount: rewrote mount options<commit_after>package mount

import (
	"flag"
	"os"
	"syscall"
	"strings"
)

var (
	flagSet   = flag.NewFlagSet("mount", flag.PanicOnError)
	typeFlag  = flagSet.String("t", "", "Filesystem type of the mount")
	flagsFlag = flagSet.String("o", "defaults", "Comma-separated list of flags for the mount")
	helpFlag  = flagSet.Bool("help", false, "Show this help")
)

func Mount(call []string) os.Error {
	e := flagSet.Parse(call[1:])
	if e != nil {
		return e
	}

	if flagSet.NArg() != 2 || *helpFlag {
		println("`mount` [options] <device> <dir>")
		flagSet.PrintDefaults()
		println("\nAvailable options are:")
		for opt, _ := range flagMap {
			print(opt, ", ")
		}
		println()
		return nil
	}

	flags, e := parseFlags()
	if e != nil {
		return e
	}

	errno := syscall.Mount(flagSet.Arg(0), flagSet.Arg(1), *typeFlag, flags, "")
	if errno != 0 {
		return os.NewError(syscall.Errstr(errno))
	}
	return nil
}

var (
	flagMap = map[string]int{
		"defaults":   0,
		"noatime":    syscall.MS_NOATIME,
		"nodev":      syscall.MS_NODEV,
		"nodiratime": syscall.MS_NODIRATIME,
		"noexec":     syscall.MS_NOEXEC,
		"nosuid":     syscall.MS_NOSUID,
		"remount":    syscall.MS_REMOUNT,
		"ro":         syscall.MS_RDONLY,
		"sync":       syscall.MS_SYNCHRONOUS,
	}
)

func parseFlags() (int, os.Error) {
	ret := 0
	parts := strings.Split(*flagsFlag, ",")
	for _, part := range parts {
		part = strings.TrimSpace(part)
		val, ok := flagMap[strings.ToLower(part)]
		if !ok {
			return 0, os.NewError("Invalid flag \"" + part + "\"")
		}
		ret |= val
	}
	return ret, nil
}

{'fraction_non_alphanumeric': 0.1686143572621035, 'fraction_numerical': 0.005008347245409015, 'mean_word_length': 3.5393939393939395, 'pattern_counts': {'":': 15, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '332350', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1138, 'n_words': 262}