🫩🫩🫩🫩

  • Seefra 1@lemmy.zip
    link
    fedilink
    arrow-up
    10
    ·
    13 days ago

    “Hey Linux, can you just delete this file please?”

    “Sure thing bud, a program is using it, it’s ok, I will just unlink the inode anyway, the program can still access it until it closes the file”

    • xthexder@l.sw0.com
      link
      fedilink
      arrow-up
      5
      ·
      13 days ago

      This is honestly one of my favorite features of the linux filesystem. As a dev it makes things like replacing and hot-reloading plugins way easier.

      It turns out you can kind of get the same functionality on Windows if you rename the open file and place the new one with the original name, but it’s a bit of a hack.

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

        It turns out you can kind of get the same functionality on Windows if you rename the open file and place the new one with the original name, but it’s a bit of a hack.

        Only if you don’t have OneDrive working. In that case, you have to wait for it to sync or it won’t go through.

        Anytime I have an issue at work where I can’t change or delete a file, it’s a 50/50 split between Excel and OneDrive being the cause

      • optional@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        7 days ago

        Yes. On Linux/Unix you don’t delete the file, you just delete it’s name, which is merely a link to the actual file. That’s also the reason why the syscalls name is actually unlink and not delete. As soon as there’s nothing pointing to a file anymore, it is deleted.

        As long as a process holds a file handle, there’s still a reference to said file, so it won’t be deleted. That saved me once, when I accidentally deleted a file I wanted to keep: As there still was some process keeping it alive, I could just go to /proc/[process id]/fd/[file descriptor id] and copy it to a safe location.

        • CanadaPlus@lemmy.sdf.org
          link
          fedilink
          arrow-up
          1
          ·
          7 days ago

          Good to know, and helps me understand code dealing with filesystems a little better. I’m curious how the kernel keeps track of it all, just a counter maybe?

          On Linux/Unix you don’t delete the file, you just delete it’s name, which is merely a link to the actual file.

          Is that different on other systems?

          • optional@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            2
            ·
            6 days ago

            I don’t know how NTFS does it, but on FAT filesystems the directory table contains the filename along with all the other file metadata (access rights, creation date, size, etc). Only the list of sectors containing the actual data is separate. That means that you can’t have two filenames for the same file on FAT filesystems.

            If you want to learn more about this, the data structure UNIX filesystems use, and FAT filesystems lack is called inode.

    • Sundray@lemmus.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      13 days ago

      “Time to see who’s stopping me from deleting this file… svchost??? Goddamn it!”

      • fibojoly@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        13 days ago

        I’m in this picture and I don’t like it. I was trying to diagnose a prod server crashing this very Wednesday and seeing the lines of svchost.exe is so fucking maddening… I’m glad ProcessExplorer was there to give some useful fucking info, at least.

      • Anivia@feddit.org
        link
        fedilink
        arrow-up
        1
        ·
        13 days ago

        Well, it could be an executable disguising itself as svchost. Pretty common for malware or video game cheats to name their executables svchost.exe to hide from anti-virus/anticheat

    • affenlehrer@feddit.org
      link
      fedilink
      arrow-up
      0
      ·
      13 days ago

      The performance view thing that comes with windows also allows searching for file handles but it’s not very user friendly. Also not possible without admin rights if I remember correctly

  • judgyweevil@feddit.it
    link
    fedilink
    arrow-up
    1
    ·
    13 days ago

    Me: I’ve closed the program, now please delete the file

    Windows: ok, give me half an hour, it’s not easy to delete 500 MB

    • krooklochurm@lemmy.ca
      link
      fedilink
      arrow-up
      0
      ·
      13 days ago

      Hey Linux, sudo rm -rf /

      sigh I’m surrounded by idiots.

      “Sure thing boss” you fucking moron.

  • finitebanjo@piefed.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    13 days ago

    TBF the task manager and those windows explorer dialogues were programed in like 1996 and it’s probably one of the best functioning feature in Windows so changing it too much carries high risks.

    • undefined@lemmy.hogru.ch
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      12 days ago

      changing it too much carries high risks

      This is such a Windows way of thinking. Why does every other OS constantly change and evolve but Windows is like “can’t touch this code from a quarter century ago?”

      • finitebanjo@piefed.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        13 days ago

        I don’t see the problem with it. Microsoft historically does a great job of making everything worse with updates.