Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support symlinks on core backends #268

Open
pyramation opened this issue Jan 21, 2019 · 12 comments
Open

Support symlinks on core backends #268

pyramation opened this issue Jan 21, 2019 · 12 comments
Milestone

Comments

@pyramation
Copy link

I've been reading the docs and I'm under the impression that the core filesystems have symlinks?

I'm currently getting ENOTSUP not supported errors, so curious if there are any examples or pointers for getting symlinks to work, thanks!

@pyramation
Copy link
Author

any one know how to create symlinks? Apparently they are readable, which is a good sign!

any help appreciated: https://stackoverflow.com/questions/55131565/how-to-create-a-symlink-within-browserfs

@jvilk 🙏🏻

@pyramation pyramation changed the title which filesystem have symlinks implemented? how to create symlinks in browserfs Mar 12, 2019
@jvilk
Copy link
Owner

jvilk commented Mar 21, 2019

@pyramation I don't believe any backend currently supports symlinks. The basic abstraction is there should someone want to implement a backend that supports them, but I never got around to supporting them in the core backends.

@pyramation
Copy link
Author

pyramation commented Mar 21, 2019

Thank you @jvilk!

Do you have an idea of how one could implement it for the Memory or LocalStorage backends? I'd be happy to dive in if there are some conceptual models for how to create the symlink.

I had one idea... I did look into potentially changing modes, and setting the contents manually. I found from this link that symlinks are mode 120000. I quickly realized I didn't know what the actual contents of a symlink look like, and couldn't find much info out there on the net or empirically in my shell (the OS wouldn't let me modify the mode of a sym link to turn it into a file and look at contents).

Any pointers on this thread are appreciated and I imagine would contribute to the creation of this feature ;)

@jvilk jvilk added the question label May 29, 2019
@jvilk
Copy link
Owner

jvilk commented May 29, 2019

The contents of a symlink is the path to the file you're symlinking. So a symlink to ../foo will contain ../foo. It's symbolic, so if you delete ../foo and bring it back, your symlink will point to the new foo. If you rename ../foo, you'll have a broken symlink.

To implement symlinks, you'll need to somehow denote in the metadata of the file that it's a symlink (I think it's stashed in the mode as you suspect -- we stash file/dir in the mode as well), and then store it as a file with the contents of the symlink.

@pyramation
Copy link
Author

Thanksd @jvilk ! I tried this out, and having issues editing mode. What's the best way to edit the mode or get into the metadata? I'm attempting to use chmodSync and getting ENOTSUP errors.

I'm trying to use chmod because If we try and write the mode on creation, we get issues because of umask, e.g.,

    fs.writeFileSync("value.txt", "hello world");
    fs.writeFileSync("alias", "./value.txt", {
      mode: 12000
    });
    console.log(fs.statSync("alias").mode.toString(8));

Which prints 127340 instead of 12000 because of UNIX permissions and umask, which makes sense. So in attempt to set mode after creation,

    fs.chmodSync("alias", 12000);

Then I get a nice not supported error: Error: ENOTSUP: Operation is not supported.

@abhishiv
Copy link

abhishiv commented Jan 10, 2020

Hey @pyramation, did you manage to figure this out. I'm hitting the same problem.

Also, from the link that you posted should the mode change due to unix permissions for symlinks? It might make it easy to implement it If it doesn't.

In addition, on Linux systems you can't specify a symlink's permissions; all that matters is the target's permission (and effectively the full mode since that determines the symlink's behaviour too).

Also would readdir/readlink support symlinks automatically if we can figure this out? I think readdir might, but how would readlink know that it's a symlink if the mode changes? Does lstat help?

  /**
   * @return [Boolean] True if this item is a symbolic link (only valid through lstat)
   */
  public isSymbolicLink(): boolean {
    return (this.mode & 0xF000) === FileType.SYMLINK;
  }

@pyramation
Copy link
Author

hey @abhishiv I don't think I ever got this working, nor did I see if there was work on it. Happy to see that more people want this feature, hopefully it can happen :)

@james-pre
Copy link
Collaborator

james-pre commented Mar 10, 2023

@pyramation

I'm attempting to use chmodSync and getting ENOTSUP errors.

chmod is supported with #334

If you do get it working a PR would definitely be welcome.

@james-pre james-pre changed the title how to create symlinks in browserfs Support symlinks on core backends Mar 26, 2023
@james-pre james-pre self-assigned this Apr 28, 2023
@abhishiv
Copy link

abhishiv commented May 13, 2023

Hey @james-pre Has #334 been release? I'm on 1.4.3, and I still get ENOTSUP

EDIT: also doesn't work with 2.0.0

@james-pre
Copy link
Collaborator

james-pre commented May 13, 2023

@abhishiv #334 is merged. I'm currently working on getting NPM publish permissions from jvilk but for now it will have to be built from the main branch.

Note that #334 does not add symlinks (only chmod/chown support).

@james-pre
Copy link
Collaborator

Also, @abhishiv I plan on working on this after I get the internal API converted to promises. It is long overdue and something that should be relatively easy to implement.

@james-pre
Copy link
Collaborator

james-pre commented Oct 25, 2023

Please use zen-fs/core#17

@james-pre james-pre closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
Repository owner locked and limited conversation to collaborators Oct 25, 2023
@james-pre james-pre reopened this May 17, 2024
Repository owner unlocked this conversation May 17, 2024
@james-pre james-pre removed their assignment Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants