Поддержка Журнала USN (изменяют журнал) в драйвере NTFS-3G

Имя файла является просто названием файла в файловой системе, ничем более - это - просто строка.

Дескриптор файла является некоторым объектом, от того, где можно читать и/или записать. Это открыто и готовый файл. Нет только дескрипторов файлов - stdin, stdout, и stderr являются также дескрипторами, можно записать и читать от них использующий абсолютно те же функции в качестве с файлами (кроме Вас, не может, например, искать). Другие примеры дескрипторов, которые не являются файлами: именованные каналы и сетевые сокеты.

В коде дескриптор файла является переменной, указателем на что-то в ядре, которое представляет объект файла.

Например,/dev/fd/0,/dev/stdin,/proc/self/fd/0 являются всеми ссылками на/dev/pts/2. Эти четыре дескрипторов файлов, или имена файлов?

Это все - псевдофайлы, которые могут быть полезны для некоторых сценариев или программ. Можно открыть их, и открытый () возвратил бы Вас дескриптор файла.

3
13.03.2011, 15:03
1 ответ

Я не нахожу много документации для USN + ntfs-3g, но просматриваю ntfs-3g источники, в include/ntfs-3g/layout.h, я нашел следующее:

/**
 * struct NTFS_RECORD -
 *
 * The Update Sequence Array (usa) is an array of the u16 values which belong
 * to the end of each sector protected by the update sequence record in which
 * this array is contained. Note that the first entry is the Update Sequence
 * Number (usn), a cyclic counter of how many times the protected record has
 * been written to disk. The values 0 and -1 (ie. 0xffff) are not used. All
 * last u16's of each sector have to be equal to the usn (during reading) or
 * are set to it (during writing). If they are not, an incomplete multi sector
 * transfer has occurred when the data was written.
 * The maximum size for the update sequence array is fixed to:
 *    maximum size = usa_ofs + (usa_count * 2) = 510 bytes
 * The 510 bytes comes from the fact that the last u16 in the array has to
 * (obviously) finish before the last u16 of the first 512-byte sector.
 * This formula can be used as a consistency check in that usa_ofs +
 * (usa_count * 2) has to be less than or equal to 510.
 */
typedef struct {
      NTFS_RECORD_TYPES magic;/* A four-byte magic identifying the
                           record type and/or status. */
      u16 usa_ofs;            /* Offset to the Update Sequence Array (usa)
                           from the start of the ntfs record. */
      u16 usa_count;          /* Number of u16 sized entries in the usa
                           including the Update Sequence Number (usn),
                           thus the number of fixups is the usa_count
                           minus 1. */
} __attribute__((__packed__)) NTFS_RECORD;

(См. также: поле USN STANDARD_INFORMATION структуры)

Так, по-видимому, они используют USNs, но я не знаю надлежащий способ достигнуть их. Я запустил бы путем взгляда на то, как NTFS_RECORD используется, и попытайтесь работать выход API оттуда.

3
27.01.2020, 21:24

Теги

Похожие вопросы