// MkdirAll is the interface implementation for FS.
543098
func (f *FakeFS) MkdirAll(dirName string, perm os.FileMode) error {
	_, err := f.Create(dirName)
	return err
}
847919
func MkdirAll(path string, perm os.FileMode) error {
	twoAttempts := false
	err := os.MkdirAll(path, perm)
	// KBFS-3245: Simple workaround for test flake where a directory
	// seems to disappear out from under us.
	if os.IsNotExist(err) {
		twoAttempts = true
		err = os.MkdirAll(path, perm)
	}
	if err != nil {
		return errors.Wrapf(err,
			"failed to mkdir (all) %q, twoAttempts=%t", path, twoAttempts)
	}

	return nil
}
962861
func (r *Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
	log.Debug("Root ReadDirAll")

	var listing []fuse.Dirent
	for alias, k := range r.Keys {
		pid, err := peer.IDFromPrivateKey(k)
		if err != nil {
			continue
		}
		ent := fuse.Dirent{
			Name: pid.Pretty(),
			Type: fuse.DT_Dir,
		}
		link := fuse.Dirent{
			Name: alias,
			Type: fuse.DT_Link,
		}
		listing = append(listing, ent, link)
	}
	return listing, nil
}
716449
func reliableMkdirAll(dirPath string, mode os.FileMode) (err error) {
	i := 0
	for {
		// Creates all the parent directories, with mode 0777 mkdir honors system umask.
		if err = os.MkdirAll(dirPath, mode); err != nil {
			// Retry only for the first retryable error.
			if os.IsNotExist(err) && i == 0 {
				i++
				continue
			}
		}
		break
	}
	return err
}
979890
func (fl *FolderList) ReadDirAll(ctx context.Context) (res []fuse.Dirent, err error) {
	fl.fs.vlog.CLogf(ctx, libkb.VLog1, "FL ReadDirAll")
	defer func() {
		err = fl.fs.processError(ctx, libkbfs.ReadMode, err)
	}()
	session, err := fl.fs.config.KBPKI().GetCurrentSession(ctx)
	isLoggedIn := err == nil

	var favs []favorites.Folder
	if isLoggedIn {
		favs, err = fl.fs.config.KBFSOps().GetFavorites(ctx)
		if err != nil {
			return nil, err
		}
	}

	res = make([]fuse.Dirent, 0, len(favs))
	for _, fav := range favs {
		if fav.Type != fl.tlfType {
			continue
		}
		pname, err := tlf.CanonicalToPreferredName(
			session.Name, tlf.CanonicalName(fav.Name))
		if err != nil {
			fl.fs.log.Errorf("CanonicalToPreferredName: %q %v", fav.Name, err)
			continue
		}
		res = append(res, fuse.Dirent{
			Type: fuse.DT_Dir,
			Name: string(pname),
		})
	}
	return res, nil
}
902683
func (d *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (
	node fs.Node, err error) {
	ctx = d.folder.fs.config.MaybeStartTrace(ctx, "Dir.Mkdir",
		fmt.Sprintf("%s %s", d.node.GetBasename(), req.Name))
	defer func() { d.folder.fs.config.MaybeFinishTrace(ctx, err) }()

	d.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "Dir Mkdir %s", req.Name)
	defer func() { err = d.folder.processError(ctx, libkbfs.WriteMode, err) }()

	// This fits in situation 1 as described in libkbfs/delayed_cancellation.go
	err = libcontext.EnableDelayedCancellationWithGracePeriod(
		ctx, d.folder.fs.config.DelayedCancellationGracePeriod())
	if err != nil {
		return nil, err
	}

	newNode, _, err := d.folder.fs.config.KBFSOps().CreateDir(
		ctx, d.node, req.Name)
	if err != nil {
		return nil, err
	}

	child := newDir(d.folder, newNode)
	d.folder.nodesMu.Lock()
	d.folder.nodes[newNode.GetID()] = child
	d.folder.nodesMu.Unlock()
	return child, nil
}
1140522
func (d *dir) mkfile(p string) (*file, error) {
	n := d.find(p)
	if n.path() == p {
		if n.isdir() {
			return nil, errIsDir
		}

		return n.(*file), nil
	}

	dirpath, filename := path.Split(p)
	// Make any non-existent directories
	n, err := d.mkdirs(dirpath)
	if err != nil {
		return nil, err
	}

	dd := n.(*dir)
	n = &file{
		common: common{
			p:   path.Join(dd.path(), filename),
			mod: time.Now(),
		},
	}

	dd.add(n)
	return n.(*file), nil
}
33786
func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
	ents := make([]fuse.Dirent, 0, len(d.nodes))
	for name, node := range d.nodes {
		if nd, ok := node.(direnter); ok {
			de, err := nd.getDirent(name)
			if err != nil {
				return nil, err
			}
			ents = append(ents, de)
		} else {
			logrus.Errorf("%s does not have a directory entry", name)
		}
	}

	return ents, nil
}
29814
func (c *C) MkDir() string {
	path := c.tempDir.newPath()
	if err := os.Mkdir(path, 0700); err != nil {
		panic(fmt.Sprintf("Couldn't create temporary directory %s: %s", path, err.Error()))
	}
	return path
}
1112017
func IsTerminal(file *os.File) bool {
	return int(C.isatty(C.int(file.Fd()))) != 0
}
485464
func (r *Root) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (_ fs.Node, err error) {
	r.log().CDebugf(ctx, "FS Mkdir")
	defer func() { err = r.private.fs.processError(ctx, libkbfs.WriteMode, err) }()
	return nil, libkbfs.NewWriteUnsupportedError(tlfhandle.BuildCanonicalPath(r.PathType(), req.Name))
}
742293
func (fp FsPath) Mkdir(perm os.FileMode) error {
	return fp.Fs.Mkdir(fp.Path, perm)
}
1171569
func MkdirForFile(path string) error {
	return os.MkdirAll(filepath.Dir(path), DefaultDirectoryPermissions)
}
1177534
func (pl ProfileList) ReadDirAll(_ context.Context) (res []fuse.Dirent, err error) {
	profiles := pprof.Profiles()
	res = make([]fuse.Dirent, 0, len(profiles))
	for _, p := range profiles {
		name := p.Name()
		if !libfs.IsSupportedProfileName(name) {
			continue
		}
		res = append(res, fuse.Dirent{
			Type: fuse.DT_File,
			Name: name,
		})
	}
	res = append(res, fuse.Dirent{
		Type: fuse.DT_File,
		Name: cpuProfilePrefix + "30s",
	})
	res = append(res, fuse.Dirent{
		Type: fuse.DT_File,
		Name: traceProfilePrefix + "1s",
	})
	return res, nil
}
429689
func (c *Client) Mkdir(path string, _ os.FileMode) error {
	path = FixSlashes(path)
	status := c.mkcol(path)
	if status == 201 {
		return nil
	}

	return newPathError("Mkdir", path, status)
}
813402
func (l *localFileSystem) MkDir(path string, mode int) error {
	fileMode := os.FileMode(mode & int(os.ModePerm))
	err := os.MkdirAll(path, fileMode)
	if err != nil && !os.IsExist(err) {
		return trace.ConvertSystemError(err)
	}

	return nil
}
998520
func runLs(dirname string, dirent os.FileInfo) string {
	dsys := dirent.Sys()
	if dsys == nil {
	} else if statt, ok := dsys.(*syscall.Stat_t); !ok {
	} else {
		return runLsStatt(dirent, statt)
	}

	return path.Join(dirname, dirent.Name())
}