Telegram Group & Telegram Channel
Как восстановить файл, если кто-то держит на него открытый файловый дескриптор (часть II)

Напомню, что в предыдущем посте мы пытались восстановить удаленный файл, не копируя его. У нас не получилось, но мы пробуем еще.

Пробуем. В Linux есть системный вызов linkat(). Он поддерживает флаги AT_EMPTY_PATH и AT_SYMLINK_FOLLOW, которые позволяют создать хардлинк на файл по файловому дескриптору на него (в том числе по ссылке в /proc/<pid>/fd). На StackOverflow показывают пример, как можно сделать хардлинк по файловому дескриптору:

fd = open("/tmp", O_TMPFILE | O_RDWR, 0600);
// write something to the file here
// fchown() / fchmod() it
linkat(fd, "", AT_FDCWD, "/tmp/test", AT_EMPTY_PATH);

Попробуем так же:
https://pastebin.com/tkyY2abT

Увы, не работает: программа выдает linkat: No such file or directory. Впрочем, man явно предупреждает, что ничего не выйдет, и среди ошибок упоминает

> ENOENT An attempt was made to link to a /proc/self/fd/NN file corresponding to a file that has been deleted.

Вариант с AT_SYMLINK_FOLLOW тоже ничего не дает:
https://pastebin.com/vVz3zcR0

Так что, к сожалению, остается единственный способ — копировать.



group-telegram.com/gepardchan/31
Create:
Last Update:

Как восстановить файл, если кто-то держит на него открытый файловый дескриптор (часть II)

Напомню, что в предыдущем посте мы пытались восстановить удаленный файл, не копируя его. У нас не получилось, но мы пробуем еще.

Пробуем. В Linux есть системный вызов linkat(). Он поддерживает флаги AT_EMPTY_PATH и AT_SYMLINK_FOLLOW, которые позволяют создать хардлинк на файл по файловому дескриптору на него (в том числе по ссылке в /proc/<pid>/fd). На StackOverflow показывают пример, как можно сделать хардлинк по файловому дескриптору:

fd = open("/tmp", O_TMPFILE | O_RDWR, 0600);
// write something to the file here
// fchown() / fchmod() it
linkat(fd, "", AT_FDCWD, "/tmp/test", AT_EMPTY_PATH);

Попробуем так же:
https://pastebin.com/tkyY2abT

Увы, не работает: программа выдает linkat: No such file or directory. Впрочем, man явно предупреждает, что ничего не выйдет, и среди ошибок упоминает

> ENOENT An attempt was made to link to a /proc/self/fd/NN file corresponding to a file that has been deleted.

Вариант с AT_SYMLINK_FOLLOW тоже ничего не дает:
https://pastebin.com/vVz3zcR0

Так что, к сожалению, остается единственный способ — копировать.

BY Гепардово гнездо


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/gepardchan/31

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

"We're seeing really dramatic moves, and it's all really tied to Ukraine right now, and in a secondary way, in terms of interest rates," Octavio Marenzi, CEO of Opimas, told Yahoo Finance Live on Thursday. "This war in Ukraine is going to give the Fed the ammunition, the cover that it needs, to not raise interest rates too quickly. And I think Jay Powell is a very tepid sort of inflation fighter and he's not going to do as much as he needs to do to get that under control. And this seems like an excuse to kick the can further down the road still and not do too much too soon." Given the pro-privacy stance of the platform, it’s taken as a given that it’ll be used for a number of reasons, not all of them good. And Telegram has been attached to a fair few scandals related to terrorism, sexual exploitation and crime. Back in 2015, Vox described Telegram as “ISIS’ app of choice,” saying that the platform’s real use is the ability to use channels to distribute material to large groups at once. Telegram has acted to remove public channels affiliated with terrorism, but Pavel Durov reiterated that he had no business snooping on private conversations. "Someone posing as a Ukrainian citizen just joins the chat and starts spreading misinformation, or gathers data, like the location of shelters," Tsekhanovska said, noting how false messages have urged Ukrainians to turn off their phones at a specific time of night, citing cybersafety. Elsewhere, version 8.6 of Telegram integrates the in-app camera option into the gallery, while a new navigation bar gives quick access to photos, files, location sharing, and more. And indeed, volatility has been a hallmark of the market environment so far in 2022, with the S&P 500 still down more than 10% for the year-to-date after first sliding into a correction last month. The CBOE Volatility Index, or VIX, has held at a lofty level of more than 30.
from us


Telegram Гепардово гнездо
FROM American