//export kbfsLibdokanMounted
771421
func kbfsLibdokanMounted(pfi C.PDOKAN_FILE_INFO) C.NTSTATUS {
	debug("Mounted")
	// Signal that the filesystem is mounted and can be used.
	fsTableGetErrChan(uint32(pfi.DokanOptions.GlobalContext)) <- nil
	// Dokan wants a NTSTATUS here, but is discarding it.
	return ntstatusOk
}
746749
func (ta ToAdd) ToKBFolder() keybase1.Folder {
	return ta.Folder.ToKBFolder(ta.Created)
}
910586
func (e *Store) Export(ctx context.Context, name string, opts metav1.ExportOptions) (runtime.Object, error) {
	obj, err := e.Get(ctx, name, &metav1.GetOptions{})
	if err != nil {
		return nil, err
	}
	if accessor, err := meta.Accessor(obj); err == nil {
		exportObjectMeta(accessor, opts.Exact)
	} else {
		klog.V(4).Infof("Object of type %v does not have ObjectMeta: %v", reflect.TypeOf(obj), err)
	}

	if e.ExportStrategy != nil {
		if err = e.ExportStrategy.Export(ctx, obj, opts.Exact); err != nil {
			return nil, err
		}
	} else {
		e.CreateStrategy.PrepareForCreate(ctx, obj)
	}
	return obj, nil
}
1090532
func (f Folder) ToKBFolder(created bool) keybase1.Folder {
	return keybase1.Folder{
		Name:       f.Name,
		FolderType: f.Type.FolderType(),
		Private:    f.Type != tlf.Public, // deprecated
		Created:    created,
	}
}
1200651
func kbfsLibdokanFindFiles(
	PathName C.LPCWSTR,
	FindData C.PFillFindData, // call this function with PWIN32_FIND_DATAW
	pfi C.PDOKAN_FILE_INFO) C.NTSTATUS {
	debugf("FindFiles '%v' %v", d16{PathName}, *pfi)
	return kbfsLibdokanFindFilesImpl(PathName, "", FindData, pfi)
}
361448
func InstallKBFS(context Context, binPath string, force bool, skipMountIfNotAvailable bool, timeout time.Duration, log Log) error {
	runMode := context.GetRunMode()
	label := DefaultKBFSLabel(runMode)
	kbfsService := launchd.NewService(label)
	kbfsBinPath, err := KBFSBinPath(runMode, binPath)
	if err != nil {
		return err
	}
	// Unmount any existing KBFS directory for the user.
	mountDir, err := context.GetMountDir()
	if err != nil {
		return err
	}

	skipMount := false
	_, err = os.Stat(mountDir)
	if err != nil {
		if skipMountIfNotAvailable {
			skipMount = true
		} else {
			return err
		}
	}

	plist, err := kbfsPlist(context, kbfsBinPath, label, mountDir, skipMount, log)
	if err != nil {
		return err
	}

	UninstallKBFSServices(context, log)
	log.Debug("Installing KBFS (%s, timeout=%s)", label, timeout)
	if _, err := installKBFSService(context, kbfsService, plist, timeout, log); err != nil {
		log.Errorf("error installing KBFS: %s", err)
		pid, err := fallbackStartProcessAndWaitForInfo(context, kbfsService, plist, context.GetKBFSInfoPath(), timeout, log)
		if err != nil {
			return err
		}
		log.Debug("fallback KBFS service started, pid=%d", pid)
		return nil
	}

	log.Debug("KBFS installed via launchd successfully")
	return nil
}
877608
func Mounted(fsType FsMagic, mountPath string) (bool, error) {
	var buf unix.Statfs_t
	if err := unix.Statfs(mountPath, &buf); err != nil {
		return false, err
	}
	return FsMagic(buf.Type) == fsType, nil
}
1077291
func kbfsLibdokanSetFileSecurity(
	fname C.LPCWSTR,
	SecurityInformation C.PSECURITY_INFORMATION,
	SecurityDescriptor C.PSECURITY_DESCRIPTOR,
	SecurityDescriptorLength C.ULONG,
	pfi C.PDOKAN_FILE_INFO) C.NTSTATUS {
	debug("SetFileSecurity TODO")
	return ntstatusOk
}
482758
func (m *execMounter) doExecMount(source, target, fstype string, options []string) error {
	klog.V(5).Infof("Exec Mounting %s %s %s %v", source, target, fstype, options)
	mountArgs := mount.MakeMountArgs(source, target, fstype, options)
	output, err := m.exec.Run("mount", mountArgs...)
	klog.V(5).Infof("Exec mounted %v: %v: %s", mountArgs, err, string(output))
	if err != nil {
		return fmt.Errorf("mount failed: %v\nMounting command: %s\nMounting arguments: %s %s %s %v\nOutput: %s",
			err, "mount", source, target, fstype, options, string(output))
	}

	return err
}
751678
func kbfsLibdokanCreateFile(
	fname C.LPCWSTR,
	psec C.PDOKAN_IO_SECURITY_CONTEXT,
	DesiredAccess C.ACCESS_MASK,
	FileAttributes C.ULONG,
	ShareAccess C.ULONG,
	cCreateDisposition C.ULONG,
	CreateOptions C.ULONG,
	pfi C.PDOKAN_FILE_INFO) C.NTSTATUS {
	var cd = CreateData{
		DesiredAccess:     uint32(DesiredAccess),
		FileAttributes:    FileAttribute(FileAttributes),
		ShareAccess:       uint32(ShareAccess),
		CreateDisposition: CreateDisposition(cCreateDisposition),
		CreateOptions:     uint32(CreateOptions),
	}
	debugf("CreateFile '%v' %#v pid: %v\n",
		d16{fname}, cd, pfi.ProcessId)
	fs := getfs(pfi)
	ctx, cancel := fs.WithContext(globalContext())
	if cancel != nil {
		defer cancel()
	}
	fi, status, err := fs.CreateFile(ctx, makeFI(fname, pfi), &cd)
	if isDebug {
		checkFileDirectoryFile(err, status.IsDir(), uint32(CreateOptions))
		debugf("CreateFile result: %v new-entry: %v raw %v", status.IsDir(), status.IsNew(), status)
		if err == nil && status&isValid == 0 {
			debugf("CreateFile invalid status for successful operation!")
		}
	}
	if status.IsDir() {
		pfi.IsDirectory = 1
	}
	if err == nil && !status.IsNew() && cd.CreateDisposition.isSignalExisting() {
		debugf("CreateFile adding ErrObjectNameCollision")
		err = ErrObjectNameCollision
	}
	return fiStore(pfi, fi, err)
}
797908
func KBFSServiceStatus(context Context, label string, wait time.Duration, log Log) (status keybase1.ServiceStatus) {
	if label == "" {
		status = keybase1.ServiceStatus{Status: keybase1.StatusFromCode(keybase1.StatusCode_SCServiceStatusError, "No service label")}
		return
	}
	kbfsService := launchd.NewService(label)

	status, err := serviceStatusFromLaunchd(kbfsService, context.GetKBFSInfoPath(), wait, log)
	if err != nil {
		return
	}
	bundleVersion, err := KBFSBundleVersion(context, "")
	if err != nil {
		status.Status = keybase1.StatusFromCode(keybase1.StatusCode_SCServiceStatusError, err.Error())
		return
	}
	status.BundleVersion = bundleVersion
	if status.InstallStatus == keybase1.InstallStatus_NOT_INSTALLED {
		return
	}

	installStatus, installAction, kbStatus := ResolveInstallStatus(status.Version, status.BundleVersion, status.LastExitStatus, log)
	status.InstallStatus = installStatus
	status.InstallAction = installAction
	status.Status = kbStatus
	return
}
683780
func (f *ScmpFilter) ExportPFC(file *os.File) error {
	f.lock.Lock()
	defer f.lock.Unlock()

	fd := file.Fd()

	if !f.valid {
		return errBadFilter
	}

	if retCode := C.seccomp_export_pfc(f.filterCtx, C.int(fd)); retCode != 0 {
		return syscall.Errno(-1 * retCode)
	}

	return nil
}
194377
func ExportKeysToFile(acs []*Account, fname string) error {
	f, err := os.Create(fname)
	if err != nil {
		return err
	}
	defer f.Close()
	exportAccounts(acs, f)
	return nil
}
576350
func (ckf ComputedKeyFamily) ExportPerUserKeys() (ret []keybase1.PerUserKey) {

	for _, k := range ckf.cki.PerUserKeys {
		ret = append(ret, k)
	}
	sort.Sort(perUserKeyList(ret))
	return ret
}
33959
func WriteToDisk(filename string, kubeconfig *clientcmdapi.Config) error {
	err := clientcmd.WriteToFile(*kubeconfig, filename)
	if err != nil {
		return err
	}

	return nil
}
34001
func (c *KBFSContext) GetKBFSSocket(clearError bool) (
	net.Conn, rpc.Transporter, bool, error) {
	var err error
	c.g.Trace("GetSocket", func() error { return err })()

	// Protect all global socket wrapper manipulation with a
	// lock to prevent race conditions.
	c.kbfsSocketMtx.Lock()
	defer c.kbfsSocketMtx.Unlock()

	needWrapper := false
	if c.kbfsSocketWrapper == nil {
		needWrapper = true
		c.g.Log.Debug("empty socket wrapper; need a new one")
	} else if c.kbfsSocketWrapper.Transporter != nil && !c.kbfsSocketWrapper.Transporter.IsConnected() {
		// need reconnect
		c.g.Log.Debug("rpc transport isn't connected, reconnecting...")
		needWrapper = true
	}

	isNew := false
	if needWrapper {
		sw := libkb.SocketWrapper{}
		if c.kbfsSocket == nil {
			sw.Err = fmt.Errorf("Cannot get socket")
		} else {
			sw.Conn, sw.Err = c.kbfsSocket.DialSocket()
			c.g.Log.Debug("DialSocket -> %s", libkb.ErrToOk(sw.Err))
			isNew = true
		}
		if sw.Err == nil {
			sw.Transporter = c.newTransportFromSocket(sw.Conn)
		}
		c.kbfsSocketWrapper = &sw
	}

	// Return the current error no matter what
	sw := c.kbfsSocketWrapper
	if sw.Err != nil && clearError {
		c.kbfsSocketWrapper = nil
	}

	return sw.Conn, sw.Transporter, isNew, sw.Err
}
410490
func GetProcNFSDExports() (map[string]ProcNFSDExports, error) {
	// read in the file
	data, err := ioutil.ReadFile(GetProcNFSDExportsFilePath())
	if err != nil {
		return nil, err
	}

	exports := make(map[string]ProcNFSDExports)
	scanner := bufio.NewScanner(strings.NewReader(string(data)))
	linenum := 0
	for scanner.Scan() {
		line := strings.TrimSpace(scanner.Text())

		linenum++
		glog.V(4).Infof("%d: %s", linenum, line)
		if strings.HasPrefix(line, "#") {
			continue
		}

		fields := strings.Fields(line)
		switch len(fields) {
		case 0:
			continue
		case 1:
			glog.Errorf("expected at least 2 fields, got %d: %s", len(fields), line)
			continue
		}

		svr := ProcNFSDExports{
			MountPoint:    fields[0],
			ClientOptions: make(map[string]NFSDExportOptions),
		}
		for _, clientSpec := range fields[1:] {
			parts := strings.Split(clientSpec, "(")
			switch len(parts) {
			case 0:
				continue
			case 1:
				glog.Errorf("expected at least 2 parts, got %d: %s", len(parts), clientSpec)
				continue
			}

			svr.ClientOptions[parts[0]] = parseOptions(strings.TrimSuffix(parts[1], ")"))
		}

		exports[svr.MountPoint] = svr
	}

	glog.V(4).Infof("nfsd exports: %+v", exports)
	return exports, nil
}