• rumba@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    12 days ago

    You used to be able to sudo cat /proc/kcore > /dev/dsp and listen to your ram

      • rumba@lemmy.zip
        link
        fedilink
        English
        arrow-up
        0
        ·
        11 days ago

        It was before OSS was taken over by ALSA (and other things) for sound. OSS let you play loose and fast and was very forgiving. I just tried using pulseaudio to do it and barely got a burble of static out of it.

        • MonkeMischief@lemmy.today
          link
          fedilink
          arrow-up
          0
          ·
          9 days ago

          That is super rad. I wonder how hard it would be to replicate today.

          We could have a “RAMcore” subgenre. I wonder how running different processes affects the sound?

          Imagine if the German underground scene discovered RAM noises. . .damn, RAMmstein is already taken. XD

          All seriousness though…I now wanna know what my RAM sounds like. Lol

          • rumba@lemmy.zip
            link
            fedilink
            English
            arrow-up
            0
            ·
            9 days ago

            Stand up an old VM that still has OSS. I screwed around with current drivers and didn’t get anything cool sounding.

      • rumba@lemmy.zip
        link
        fedilink
        English
        arrow-up
        0
        ·
        11 days ago

        it rotated in between white noise, strobing sirens, digital corruption and silence.

  • pelya@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    13 days ago

    Do you know how to build portable executables?

    configure --prefix=/proc/self/pwd
    

    It even works in .so files and libtool.

      • pelya@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        13 days ago

        --prefix=$(pwd) is resolved at compile time. If you move your compiled .so files to a different directory, they stop working.

        • eleijeep@piefed.social
          link
          fedilink
          English
          arrow-up
          0
          ·
          13 days ago

          I see what you mean, very clever solution if a program is using the configure prefix by compiling it into the binary.

          That can’t be very common though is it? Usually the configure prefix is just used by make install to install the binaries into the prefix. If the compiled program needs to know where it is installed it can read argv[0].

          Have you seen this used somewhere?

          • pelya@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            13 days ago

            I am using this myself in Android app, where you can write files only inside /data/data/your.app.id/

            So naturally, if you want to publish a different app, your.app.id will be different, so you need to recompile all your Linux tools that you bundle inside your app.

            If you are not running your Linux tools on Android, you’d probably be better off using Docker or a chroot.

      • pelya@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        13 days ago

        The executable will search for .so files not inside predefined paths like /usr/lib but inside it’s current directory. You may theoretically put . as an argument to configure, but it converts that into an absolute path, snd libtool and linker fail when encountering relative paths inside shared library dependencies.

  • lyralycan@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    13 days ago

    Great tips! Although if i may 🤓 just a little for the top right, it works because what you deleted isn’t the binary, it’s the pointer that points to the binary’s location. The data is still exactly as it was before “deletion”; the symlink is simply a copy of the original pointer’s info; and I’m speculating that the existence of any pointer prevents the system from recycling those addressed bits.

    • bruh@nord.pub
      link
      fedilink
      English
      arrow-up
      0
      ·
      13 days ago

      it merely deletes the inode from the directory instead of overwriting the actual data on the disk

  • otacon239@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    13 days ago

    Okay, this is legitimately cool as heck. This finally helps me wrap my head around the “everything is a file” concept in Linux. Of course it can just copy the executable to memory for later reference. That’s how the system would not completely have a meltdown when you do live updates.

    Excellent share!

    • HiddenLayer555@lemmy.ml
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      13 days ago

      I bet this is done with inodes. Deleted files aren’t truely deleted until nothing has it open and its inode gets dropped. Like ARC for files.

      You can also do interesting things like overwrite a “file” (as in a specific filesystem path) with new contents while keeping anything that already has the file open on the old contents by unlinking the old inode to the path and writing the new contents under a new inode. I believe mv does this. The kind of lesser known feature that probably strikes a good balance between preventing super annoying silent errors/corruption and causing them.

      Relevant Kevin Fang video

      • AlteredEgo@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        13 days ago

        Thanks for explaining, I was wondering about that.

        Wait, is that why renaming or moving files on android takes forever?

        • diaphragmwp@discuss.tchncs.de
          link
          fedilink
          English
          arrow-up
          0
          ·
          13 days ago

          No, that’s because Android. It’s also overlaying all filesystems to enforce stupid rules, like no files named “CON” and no files named the same in a different case (like in DOS).

    • atzanteol@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      0
      ·
      13 days ago

      It’s a bit more interesting than that…

      Linux, unlike Windows, will let you delete a file that is actively in use. It removes the reference on the file system but the contents of the file won’t be deleted until all file pointers to it close. In fact it will still be seen as taking up disk space until it’s garbage collected (deleting a large file that’s in use can be frustrating).

      So the file is actually still available to that running process. If you replace it with a new executable and run that then you get the new version.

  • muusemuuse@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 days ago

    I never really considered using proc to solve my problems. I jump to logs and such but honestly, how have I never played with proc?

  • utopiah@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    12 days ago

    I have some of her paper zines on my desk, warmly recommended.

    Might look esoteric at first but if you think we will be using Linux at least on desktop, servers, consoles and more for decades then totally worth learning about.

  • provectus@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    13 days ago

    Did you know openBSD does not have this folder? I think the BSD’s do not use /proc. I do not know why though.

    • SlurpingPus@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      13 days ago

      That raises the question of how their ps, top, lsof and such work, since afaik in Linux they read from /proc.

      P.S. Looks like BSDs tug at the kernel via syscalls, namely sysctl and also the ‘kvm interface’ in the case of MacOS (not sure what ‘kvm’ thing is meant here). Seems vaguely reasonable, since procfs also queries the kernel for the info, so about the same resources would be used, perhaps even with the overhead of filesystem traversal and string-numbers conversion.

      • provectus@lemmy.ml
        link
        fedilink
        English
        arrow-up
        0
        ·
        12 days ago

        I might be mistaken, but I think kvm stands for kernel virtual machine. Having no /proc, and interacting with sysctl instead sounds more secure, IMO.

  • four@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    13 days ago

    I’m surprised it doesn’t mention that /proc/self automagically points to the directory of the current process. So if you’re writing a program, you can just look there for information about itself

  • jaybone@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    13 days ago

    I seem to recall in an Operating Systems class we wrote a kernel module and communicated with it through the proc interface?

    • white_nrdy@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      13 days ago

      I may have been through “SysFS” as well? In /sys/class you can setup char dev IO with a kernel module (and more). Very helpful for userspace <-> kernel communication (like DMA drivers for userspace applications)

      • jaybone@lemmy.zip
        link
        fedilink
        English
        arrow-up
        0
        ·
        13 days ago

        Hmm yeah maybe it was /sys, it’s been so long I can’t remember.

        I seem to recall echoing into a file to set some value which we then checked the value of in the kernel module code. It was just a hello world type of thing for a college class.