{"record":{"id":"3609a58071e24a4f","repo":"juicedata/juicefs","slug":"mkdir-s","errorCode":null,"errorMessage":"mkdir %s","messagePattern":"mkdir %s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/nfs.go","lineNumber":424,"sourceCode":"\t\t\tUID: nfs.SetUID{\n\t\t\t\tSetIt: true,\n\t\t\t\tUID:   uint32(uid),\n\t\t\t},\n\t\t\tGID: nfs.SetUID{\n\t\t\t\tSetIt: true,\n\t\t\t\tUID:   uint32(gid),\n\t\t\t},\n\t\t}\n\t})\n}\n\nfunc (n *nfsStore) Symlink(oldName, newName string) error {\n\tnewName = strings.TrimRight(newName, \"/\")\n\tp := n.path(newName)\n\tdir := path.Dir(p)\n\tif _, _, err := n.target.Lookup(dir); err != nil && os.IsNotExist(err) {\n\t\tif _, err := n.target.Mkdir(dir, n.dmode); err != nil && !os.IsExist(err) {\n\t\t\treturn errors.Wrapf(err, \"mkdir %s\", dir)\n\t\t}\n\t} else if err != nil && !os.IsNotExist(err) {\n\t\treturn err\n\t}\n\treturn n.target.Symlink(n.path(oldName), n.path(newName))\n}\n\nfunc (n *nfsStore) Readlink(name string) (string, error) {\n\tf, err := n.target.Open(n.path(name))\n\tif err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"open %s\", name)\n\t}\n\treturn f.Readlink()\n}\n\nfunc (n *nfsStore) ListAll(ctx context.Context, prefix, marker string, followLink bool) (<-chan Object, error) {\n\treturn nil, notSupported\n}","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/nfs.go#L406-L442","documentation":"This error comes from nfsStore.Symlink in pkg/object/nfs.go:424. When creating a symlink whose parent directory does not yet exist, the store first attempts to Mkdir that parent; if Mkdir fails with an error that is not os.ErrExist (e.g. permission denied, I/O error on the NFS mount), the mkdir failure is wrapped with the target directory path and returned. It is a wrapper, so the root cause (the underlying syscall error) is in the wrapped chain.","triggerScenarios":"Calling Symlink(oldName, newName) on an NFS-backed object store where path.Dir(newName) does not exist AND the automatic Mkdir of that parent fails with a non-IsExist error (e.g. EACCES, EROFS, EIO on the NFS export).","commonSituations":"NFS export mounted read-only or with squashed permissions (root_squash), so the JuiceFS process cannot create intermediate directories; network/permission issues on the underlying target filesystem when writing via the NFS object-store backend.","solutions":["Check permissions on the parent path of the target name on the NFS mount; ensure the process user can mkdir there (check /etc/exports squash options).","Verify the NFS mount is not read-only (mount | grep nfs; remount rw if needed).","Pre-create the parent directory manually with the correct ownership, then retry the operation.","Inspect the wrapped root-cause error in the message chain to fix the underlying syscall problem."],"exampleFix":"// before (fails: parent dir missing, cannot be created)\nstore.Symlink(\"/data/target\", \"/mnt/nfs/dir/sub/link\")\n\n// after: ensure parent exists and is writable first\nos.MkdirAll(\"/mnt/nfs/dir/sub\", 0o755)\nstore.Symlink(\"/data/target\", \"/mnt/nfs/dir/sub/link\")","handlingStrategy":"try-catch","validationCode":"p := \"/mnt/nfs/dir/sub\"\nif _, err := os.Stat(p); err != nil {\n    if err := os.MkdirAll(p, 0o755); err != nil {\n        return fmt.Errorf(\"cannot create parent dir %s: %w\", p, err)\n    }\n}\n// also verify writability\nif err := unix.Access(p, unix.W_OK); err != nil { return err }","typeGuard":null,"tryCatchPattern":"err := store.Symlink(old, new)\nif err != nil {\n    var pe *os.PathError\n    if errors.As(err, &pe) && (errors.Is(err, syscall.EACCES) || errors.Is(err, syscall.EROFS)) {\n        // fix permissions / remount rw, then retry\n    }\n    return err\n}","preventionTips":["Pre-create parent directories with correct ownership before writing through the NFS store.","Run the client with a user permitted to write on the NFS export (watch for root_squash).","Monitor the NFS mount for read-only or stale states."],"tags":["nfs","filesystem","mkdir","symlink","permissions"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}