Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Most of Apps break hardlinks system!

Off-Topic discussions about science, technology, and non Debian specific topics.
Post Reply
Message
Author
User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Most of Apps break hardlinks system!

#1 Post by bester69 »

Hi,

Do you know why most of apps cant work with hardlinks without breaking the hardlink?..Shouldn't kernel be able to manage this at low level?. I find it extrange :shock:

There are some apps can manage hardlinks like libreoffice, most of text editors, but when working with images or movies, I saw those programs create a new file with the source breaking the hardlink (gimp, jpegoptim, etc)..

For example, I couldnt apply jpegoptim to hardlink files, without using tweaking script.:
find ./ -name "*.jpg" -exec jpegoptim -S70 "{}" \;
>>> This sentence break all hardlinks when recompressing image files.

For example, To using GImp with a hardlink we would need to apply a script code like this.:

Code: Select all

#!/bin/sh
#
cp $1 $2
gimp $2
cat $2 > $1
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Most of Apps break hardlinks system!

#2 Post by bw123 »

bester69 wrote: ...
Do you know why most of apps cant work with hardlinks without breaking the hardlink?..Shouldn't kernel be able to manage this at low level?. I find it extrange :shock:
...
I don't know why, but I have noticed the same in many cases. I'm not sure I'd say it was "most apps," but yeah most windows/cross platform apps that have been ported to linux seem to do this... and they do it silently. It is very annoying.

I think it might be because one way to update/overwrite a file is to delete it and replace it with a new file. Also, it seems many programmers don't understand linux from the user point of view.

Editing a file as a tmp and moving it over the link has the same result. Some aps have an "edit in place" flag, or a setting to follow symlinks, but I don't think that is consistent feature.

Code: Select all

$ echo "this is foofile" > foofile
$ ln foofile foolink
$ cat foolink
this is foofile
$ echo "this is foofiletmp" > foofiletmp
$ mv foofiletmp foolink
$ cat foolink
this is foofiletmp
$ cat foofile
this is foofile
resigned by AI ChatGPT

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Most of Apps break hardlinks system!

#3 Post by bester69 »

bw123 wrote:
bester69 wrote: ...
Do you know why most of apps cant work with hardlinks without breaking the hardlink?..Shouldn't kernel be able to manage this at low level?. I find it extrange :shock:
...
I don't know why, but I have noticed the same in many cases. I'm not sure I'd say it was "most apps," but yeah most windows/cross platform apps that have been ported to linux seem to do this... and they do it silently. It is very annoying.
..
yeah, they do it silently... I have litle space in disk and love hardlinks to work with.


For example, for using "jpegoptim" with "find" I had to create a wrapper script to proccess operations and keep unbroken hardlinks.


Example.:

Code: Select all

#!/bin/bash
#
find . -name "*.jpg" -maxdepth 1  -exec /home/user/scripts/jpegminfind.sh  "{}" \;
jpegminfind.sh

Code: Select all

#!/bin/bash
#
TAG="$1"

cp "$TAG" "$TAG".bak
jpegoptim -S70  "$TAG".bak
cat "$TAG".bak >"$TAG"
rm "$TAG".bak
We will have to be carefully :?
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: Most of Apps break hardlinks system!

#4 Post by bw123 »

bester69, do you think there might be a way to tweak the fs to change this? I don't think it's a kernel issue, probably something in the way the filesystem presents the file to the thing opening it? Does every app opening a file need to test for hard link and warn, or test on save? Most apps ask, "Do you want to replace?" but they don't mention that you will replace a link with a file.

Heck yeah, VERY annoying.
resigned by AI ChatGPT

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: Most of Apps break hardlinks system!

#5 Post by bester69 »

bw123 wrote:bester69, do you think there might be a way to tweak the fs to change this? I don't think it's a kernel issue, probably something in the way the filesystem presents the file to the thing opening it? Does every app opening a file need to test for hard link and warn, or test on save? Most apps ask, "Do you want to replace?" but they don't mention that you will replace a link with a file.

Heck yeah, VERY annoying.
You're right; we need a smart solution here, I guess Filesystem and kernel should work together to manage an intelligence solution.

Furthermore, Graphicals desktop should add some kind of shortcut symbol/arrow to show they're hardlinks.. I think Torvalds might no be very pro hardlinks ways.

:)
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Most of Apps break hardlinks system!

#6 Post by p.H »

bester69 wrote:Filesystem and kernel should work together to manage an intelligence solution.
This is neither a kernel nor filesystem issue. It is a userland issue.
When userland asks the kernel to :
- open file A in read mode
- create/open file B in write mode
- read into A
- write into B
- move/rename B to A (which implies removing A)

How should the kernel figure out that it should actually copy the contents of B into A and remove B instead of the expected specified behaviour ? The userland should explicitly ask for this if this is what it wants. Hardlinks and symlinks are basic Unix filesystem features. Userland has to deal with them.

Post Reply