2 * logfile.c - NTFS journal handling. Originated from the Linux-NTFS project.
4 * Copyright (c) 2002-2005 Anton Altaparmakov
5 * Copyright (c) 2005 Yura Pakhuchiy
6 * Copyright (c) 2005-2009 Szabolcs Szakacsits
8 * This program/include file is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program/include file is distributed in the hope that it will be
14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program (in the main directory of the NTFS-3G
20 * distribution in the file COPYING); if not, write to the Free Software
21 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
47 * ntfs_check_restart_page_header - check the page header for consistency
48 * @rp: restart page header to check
49 * @pos: position in logfile at which the restart page header resides
51 * Check the restart page header @rp for consistency and return TRUE if it is
52 * consistent and FALSE otherwise.
54 * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not
55 * require the full restart page.
57 static BOOL
ntfs_check_restart_page_header(RESTART_PAGE_HEADER
*rp
, s64 pos
)
59 u32 logfile_system_page_size
, logfile_log_page_size
;
60 u16 ra_ofs
, usa_count
, usa_ofs
, usa_end
= 0;
63 ntfs_log_trace("Entering.\n");
65 * If the system or log page sizes are smaller than the ntfs block size
66 * or either is not a power of 2 we cannot handle this log file.
68 logfile_system_page_size
= le32_to_cpu(rp
->system_page_size
);
69 logfile_log_page_size
= le32_to_cpu(rp
->log_page_size
);
70 if (logfile_system_page_size
< NTFS_BLOCK_SIZE
||
71 logfile_log_page_size
< NTFS_BLOCK_SIZE
||
72 logfile_system_page_size
&
73 (logfile_system_page_size
- 1) ||
74 logfile_log_page_size
& (logfile_log_page_size
- 1)) {
75 ntfs_log_error("$LogFile uses unsupported page size.\n");
79 * We must be either at !pos (1st restart page) or at pos = system page
80 * size (2nd restart page).
82 if (pos
&& pos
!= logfile_system_page_size
) {
83 ntfs_log_error("Found restart area in incorrect "
84 "position in $LogFile.\n");
88 * We only know how to handle version 1.1 and 2.0, though
89 * version 2.0 is probably related to cached metadata in
90 * Windows 8, and we will refuse to mount.
91 * Nevertheless, do all the relevant checks before rejecting.
93 if (((rp
->major_ver
!= const_cpu_to_le16(1))
94 || (rp
->minor_ver
!= const_cpu_to_le16(1)))
95 && ((rp
->major_ver
!= const_cpu_to_le16(2))
96 || (rp
->minor_ver
!= const_cpu_to_le16(0)))) {
97 ntfs_log_error("$LogFile version %i.%i is not "
98 "supported.\n (This driver supports version "
99 "1.1 and 2.0 only.)\n",
100 (int)sle16_to_cpu(rp
->major_ver
),
101 (int)sle16_to_cpu(rp
->minor_ver
));
105 * If chkdsk has been run the restart page may not be protected by an
106 * update sequence array.
108 if (ntfs_is_chkd_record(rp
->magic
) && !le16_to_cpu(rp
->usa_count
)) {
110 goto skip_usa_checks
;
112 /* Verify the size of the update sequence array. */
113 usa_count
= 1 + (logfile_system_page_size
>> NTFS_BLOCK_SIZE_BITS
);
114 if (usa_count
!= le16_to_cpu(rp
->usa_count
)) {
115 ntfs_log_error("$LogFile restart page specifies "
116 "inconsistent update sequence array count.\n");
119 /* Verify the position of the update sequence array. */
120 usa_ofs
= le16_to_cpu(rp
->usa_ofs
);
121 usa_end
= usa_ofs
+ usa_count
* sizeof(u16
);
122 if (usa_ofs
< sizeof(RESTART_PAGE_HEADER
) ||
123 usa_end
> NTFS_BLOCK_SIZE
- sizeof(u16
)) {
124 ntfs_log_error("$LogFile restart page specifies "
125 "inconsistent update sequence array offset.\n");
130 * Verify the position of the restart area. It must be:
131 * - aligned to 8-byte boundary,
132 * - after the update sequence array, and
133 * - within the system page size.
135 ra_ofs
= le16_to_cpu(rp
->restart_area_offset
);
136 if (ra_ofs
& 7 || (have_usa
? ra_ofs
< usa_end
:
137 ra_ofs
< sizeof(RESTART_PAGE_HEADER
)) ||
138 ra_ofs
> logfile_system_page_size
) {
139 ntfs_log_error("$LogFile restart page specifies "
140 "inconsistent restart area offset.\n");
144 * Only restart pages modified by chkdsk are allowed to have chkdsk_lsn
147 if (!ntfs_is_chkd_record(rp
->magic
) && sle64_to_cpu(rp
->chkdsk_lsn
)) {
148 ntfs_log_error("$LogFile restart page is not modified "
149 "by chkdsk but a chkdsk LSN is specified.\n");
152 ntfs_log_trace("Done.\n");
157 * ntfs_check_restart_area - check the restart area for consistency
158 * @rp: restart page whose restart area to check
160 * Check the restart area of the restart page @rp for consistency and return
161 * TRUE if it is consistent and FALSE otherwise.
163 * This function assumes that the restart page header has already been
164 * consistency checked.
166 * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not
167 * require the full restart page.
169 static BOOL
ntfs_check_restart_area(RESTART_PAGE_HEADER
*rp
)
173 u16 ra_ofs
, ra_len
, ca_ofs
;
176 ntfs_log_trace("Entering.\n");
177 ra_ofs
= le16_to_cpu(rp
->restart_area_offset
);
178 ra
= (RESTART_AREA
*)((u8
*)rp
+ ra_ofs
);
180 * Everything before ra->file_size must be before the first word
181 * protected by an update sequence number. This ensures that it is
182 * safe to access ra->client_array_offset.
184 if (ra_ofs
+ offsetof(RESTART_AREA
, file_size
) >
185 NTFS_BLOCK_SIZE
- sizeof(u16
)) {
186 ntfs_log_error("$LogFile restart area specifies "
187 "inconsistent file offset.\n");
191 * Now that we can access ra->client_array_offset, make sure everything
192 * up to the log client array is before the first word protected by an
193 * update sequence number. This ensures we can access all of the
194 * restart area elements safely. Also, the client array offset must be
195 * aligned to an 8-byte boundary.
197 ca_ofs
= le16_to_cpu(ra
->client_array_offset
);
198 if (((ca_ofs
+ 7) & ~7) != ca_ofs
||
199 ra_ofs
+ ca_ofs
> (u16
)(NTFS_BLOCK_SIZE
-
201 ntfs_log_error("$LogFile restart area specifies "
202 "inconsistent client array offset.\n");
206 * The restart area must end within the system page size both when
207 * calculated manually and as specified by ra->restart_area_length.
208 * Also, the calculated length must not exceed the specified length.
210 ra_len
= ca_ofs
+ le16_to_cpu(ra
->log_clients
) *
211 sizeof(LOG_CLIENT_RECORD
);
212 if ((u32
)(ra_ofs
+ ra_len
) > le32_to_cpu(rp
->system_page_size
) ||
213 (u32
)(ra_ofs
+ le16_to_cpu(ra
->restart_area_length
)) >
214 le32_to_cpu(rp
->system_page_size
) ||
215 ra_len
> le16_to_cpu(ra
->restart_area_length
)) {
216 ntfs_log_error("$LogFile restart area is out of bounds "
217 "of the system page size specified by the "
218 "restart page header and/or the specified "
219 "restart area length is inconsistent.\n");
223 * The ra->client_free_list and ra->client_in_use_list must be either
224 * LOGFILE_NO_CLIENT or less than ra->log_clients or they are
225 * overflowing the client array.
227 if ((ra
->client_free_list
!= LOGFILE_NO_CLIENT
&&
228 le16_to_cpu(ra
->client_free_list
) >=
229 le16_to_cpu(ra
->log_clients
)) ||
230 (ra
->client_in_use_list
!= LOGFILE_NO_CLIENT
&&
231 le16_to_cpu(ra
->client_in_use_list
) >=
232 le16_to_cpu(ra
->log_clients
))) {
233 ntfs_log_error("$LogFile restart area specifies "
234 "overflowing client free and/or in use lists.\n");
238 * Check ra->seq_number_bits against ra->file_size for consistency.
239 * We cannot just use ffs() because the file size is not a power of 2.
241 file_size
= (u64
)sle64_to_cpu(ra
->file_size
);
247 if (le32_to_cpu(ra
->seq_number_bits
) != (u32
)(67 - fs_bits
)) {
248 ntfs_log_error("$LogFile restart area specifies "
249 "inconsistent sequence number bits.\n");
252 /* The log record header length must be a multiple of 8. */
253 if (((le16_to_cpu(ra
->log_record_header_length
) + 7) & ~7) !=
254 le16_to_cpu(ra
->log_record_header_length
)) {
255 ntfs_log_error("$LogFile restart area specifies "
256 "inconsistent log record header length.\n");
259 /* Ditto for the log page data offset. */
260 if (((le16_to_cpu(ra
->log_page_data_offset
) + 7) & ~7) !=
261 le16_to_cpu(ra
->log_page_data_offset
)) {
262 ntfs_log_error("$LogFile restart area specifies "
263 "inconsistent log page data offset.\n");
266 ntfs_log_trace("Done.\n");
271 * ntfs_check_log_client_array - check the log client array for consistency
272 * @rp: restart page whose log client array to check
274 * Check the log client array of the restart page @rp for consistency and
275 * return TRUE if it is consistent and FALSE otherwise.
277 * This function assumes that the restart page header and the restart area have
278 * already been consistency checked.
280 * Unlike ntfs_check_restart_page_header() and ntfs_check_restart_area(), this
281 * function needs @rp->system_page_size bytes in @rp, i.e. it requires the full
282 * restart page and the page must be multi sector transfer deprotected.
284 static BOOL
ntfs_check_log_client_array(RESTART_PAGE_HEADER
*rp
)
287 LOG_CLIENT_RECORD
*ca
, *cr
;
289 BOOL in_free_list
, idx_is_first
;
291 ntfs_log_trace("Entering.\n");
292 ra
= (RESTART_AREA
*)((u8
*)rp
+ le16_to_cpu(rp
->restart_area_offset
));
293 ca
= (LOG_CLIENT_RECORD
*)((u8
*)ra
+
294 le16_to_cpu(ra
->client_array_offset
));
296 * Check the ra->client_free_list first and then check the
297 * ra->client_in_use_list. Check each of the log client records in
298 * each of the lists and check that the array does not overflow the
299 * ra->log_clients value. Also keep track of the number of records
300 * visited as there cannot be more than ra->log_clients records and
301 * that way we detect eventual loops in within a list.
303 nr_clients
= le16_to_cpu(ra
->log_clients
);
304 idx
= le16_to_cpu(ra
->client_free_list
);
307 for (idx_is_first
= TRUE
; idx
!= LOGFILE_NO_CLIENT_CPU
; nr_clients
--,
308 idx
= le16_to_cpu(cr
->next_client
)) {
309 if (!nr_clients
|| idx
>= le16_to_cpu(ra
->log_clients
))
311 /* Set @cr to the current log client record. */
313 /* The first log client record must not have a prev_client. */
315 if (cr
->prev_client
!= LOGFILE_NO_CLIENT
)
317 idx_is_first
= FALSE
;
320 /* Switch to and check the in use list if we just did the free list. */
322 in_free_list
= FALSE
;
323 idx
= le16_to_cpu(ra
->client_in_use_list
);
326 ntfs_log_trace("Done.\n");
329 ntfs_log_error("$LogFile log client array is corrupt.\n");
334 * ntfs_check_and_load_restart_page - check the restart page for consistency
335 * @log_na: opened ntfs attribute for journal $LogFile
336 * @rp: restart page to check
337 * @pos: position in @log_na at which the restart page resides
338 * @wrp: [OUT] copy of the multi sector transfer deprotected restart page
339 * @lsn: [OUT] set to the current logfile lsn on success
341 * Check the restart page @rp for consistency and return 0 if it is consistent
342 * and errno otherwise. The restart page may have been modified by chkdsk in
343 * which case its magic is CHKD instead of RSTR.
345 * This function only needs NTFS_BLOCK_SIZE bytes in @rp, i.e. it does not
346 * require the full restart page.
348 * If @wrp is not NULL, on success, *@wrp will point to a buffer containing a
349 * copy of the complete multi sector transfer deprotected page. On failure,
350 * *@wrp is undefined.
352 * Similarly, if @lsn is not NULL, on success *@lsn will be set to the current
353 * logfile lsn according to this restart page. On failure, *@lsn is undefined.
355 * The following error codes are defined:
356 * EINVAL - The restart page is inconsistent.
357 * ENOMEM - Not enough memory to load the restart page.
358 * EIO - Failed to reading from $LogFile.
360 static int ntfs_check_and_load_restart_page(ntfs_attr
*log_na
,
361 RESTART_PAGE_HEADER
*rp
, s64 pos
, RESTART_PAGE_HEADER
**wrp
,
365 RESTART_PAGE_HEADER
*trp
;
368 ntfs_log_trace("Entering.\n");
369 /* Check the restart page header for consistency. */
370 if (!ntfs_check_restart_page_header(rp
, pos
)) {
371 /* Error output already done inside the function. */
374 /* Check the restart area for consistency. */
375 if (!ntfs_check_restart_area(rp
)) {
376 /* Error output already done inside the function. */
379 ra
= (RESTART_AREA
*)((u8
*)rp
+ le16_to_cpu(rp
->restart_area_offset
));
381 * Allocate a buffer to store the whole restart page so we can multi
382 * sector transfer deprotect it.
384 trp
= ntfs_malloc(le32_to_cpu(rp
->system_page_size
));
388 * Read the whole of the restart page into the buffer. If it fits
389 * completely inside @rp, just copy it from there. Otherwise read it
392 if (le32_to_cpu(rp
->system_page_size
) <= NTFS_BLOCK_SIZE
)
393 memcpy(trp
, rp
, le32_to_cpu(rp
->system_page_size
));
394 else if (ntfs_attr_pread(log_na
, pos
,
395 le32_to_cpu(rp
->system_page_size
), trp
) !=
396 le32_to_cpu(rp
->system_page_size
)) {
398 ntfs_log_error("Failed to read whole restart page into the "
405 * Perform the multi sector transfer deprotection on the buffer if the
406 * restart page is protected.
408 if ((!ntfs_is_chkd_record(trp
->magic
) || le16_to_cpu(trp
->usa_count
))
409 && ntfs_mst_post_read_fixup((NTFS_RECORD
*)trp
,
410 le32_to_cpu(rp
->system_page_size
))) {
412 * A multi sector tranfer error was detected. We only need to
413 * abort if the restart page contents exceed the multi sector
414 * transfer fixup of the first sector.
416 if (le16_to_cpu(rp
->restart_area_offset
) +
417 le16_to_cpu(ra
->restart_area_length
) >
418 NTFS_BLOCK_SIZE
- (int)sizeof(u16
)) {
419 ntfs_log_error("Multi sector transfer error "
420 "detected in $LogFile restart page.\n");
426 * If the restart page is modified by chkdsk or there are no active
427 * logfile clients, the logfile is consistent. Otherwise, need to
428 * check the log client records for consistency, too.
431 if (ntfs_is_rstr_record(rp
->magic
) &&
432 ra
->client_in_use_list
!= LOGFILE_NO_CLIENT
) {
433 if (!ntfs_check_log_client_array(trp
)) {
439 if (ntfs_is_rstr_record(rp
->magic
))
440 *lsn
= sle64_to_cpu(ra
->current_lsn
);
441 else /* if (ntfs_is_chkd_record(rp->magic)) */
442 *lsn
= sle64_to_cpu(rp
->chkdsk_lsn
);
444 ntfs_log_trace("Done.\n");
455 * ntfs_check_logfile - check in the journal if the volume is consistent
456 * @log_na: ntfs attribute of loaded journal $LogFile to check
457 * @rp: [OUT] on success this is a copy of the current restart page
459 * Check the $LogFile journal for consistency and return TRUE if it is
460 * consistent and FALSE if not. On success, the current restart page is
461 * returned in *@rp. Caller must call ntfs_free(*@rp) when finished with it.
463 * At present we only check the two restart pages and ignore the log record
466 * Note that the MstProtected flag is not set on the $LogFile inode and hence
467 * when reading pages they are not deprotected. This is because we do not know
468 * if the $LogFile was created on a system with a different page size to ours
469 * yet and mst deprotection would fail if our page size is smaller.
471 BOOL
ntfs_check_logfile(ntfs_attr
*log_na
, RESTART_PAGE_HEADER
**rp
)
474 LSN rstr1_lsn
, rstr2_lsn
;
475 ntfs_volume
*vol
= log_na
->ni
->vol
;
477 RESTART_PAGE_HEADER
*rstr1_ph
= NULL
;
478 RESTART_PAGE_HEADER
*rstr2_ph
= NULL
;
479 int log_page_size
, err
;
480 BOOL logfile_is_empty
= TRUE
;
483 ntfs_log_trace("Entering.\n");
484 /* An empty $LogFile must have been clean before it got emptied. */
485 if (NVolLogFileEmpty(vol
))
487 size
= log_na
->data_size
;
488 /* Make sure the file doesn't exceed the maximum allowed size. */
489 if (size
> (s64
)MaxLogFileSize
)
490 size
= MaxLogFileSize
;
491 log_page_size
= DefaultLogPageSize
;
493 * Use generic_ffs() instead of ffs() to enable the compiler to
494 * optimize log_page_size and log_page_bits into constants.
496 log_page_bits
= ffs(log_page_size
) - 1;
497 size
&= ~(log_page_size
- 1);
500 * Ensure the log file is big enough to store at least the two restart
501 * pages and the minimum number of log record pages.
503 if (size
< log_page_size
* 2 || (size
- log_page_size
* 2) >>
504 log_page_bits
< MinLogRecordPages
) {
505 ntfs_log_error("$LogFile is too small.\n");
508 /* Allocate memory for restart page. */
509 kaddr
= ntfs_malloc(NTFS_BLOCK_SIZE
);
513 * Read through the file looking for a restart page. Since the restart
514 * page header is at the beginning of a page we only need to search at
515 * what could be the beginning of a page (for each page size) rather
516 * than scanning the whole file byte by byte. If all potential places
517 * contain empty and uninitialized records, the log file can be assumed
520 for (pos
= 0; pos
< size
; pos
<<= 1) {
522 * Read first NTFS_BLOCK_SIZE bytes of potential restart page.
524 if (ntfs_attr_pread(log_na
, pos
, NTFS_BLOCK_SIZE
, kaddr
) !=
526 ntfs_log_error("Failed to read first NTFS_BLOCK_SIZE "
527 "bytes of potential restart page.\n");
532 * A non-empty block means the logfile is not empty while an
533 * empty block after a non-empty block has been encountered
536 if (!ntfs_is_empty_recordp((le32
*)kaddr
))
537 logfile_is_empty
= FALSE
;
538 else if (!logfile_is_empty
)
541 * A log record page means there cannot be a restart page after
542 * this so no need to continue searching.
544 if (ntfs_is_rcrd_recordp((le32
*)kaddr
))
546 /* If not a (modified by chkdsk) restart page, continue. */
547 if (!ntfs_is_rstr_recordp((le32
*)kaddr
) &&
548 !ntfs_is_chkd_recordp((le32
*)kaddr
)) {
550 pos
= NTFS_BLOCK_SIZE
>> 1;
554 * Check the (modified by chkdsk) restart page for consistency
555 * and get a copy of the complete multi sector transfer
556 * deprotected restart page.
558 err
= ntfs_check_and_load_restart_page(log_na
,
559 (RESTART_PAGE_HEADER
*)kaddr
, pos
,
560 !rstr1_ph
? &rstr1_ph
: &rstr2_ph
,
561 !rstr1_ph
? &rstr1_lsn
: &rstr2_lsn
);
564 * If we have now found the first (modified by chkdsk)
565 * restart page, continue looking for the second one.
568 pos
= NTFS_BLOCK_SIZE
>> 1;
572 * We have now found the second (modified by chkdsk)
573 * restart page, so we can stop looking.
578 * Error output already done inside the function. Note, we do
579 * not abort if the restart page was invalid as we might still
580 * find a valid one further in the file.
584 /* Continue looking. */
586 pos
= NTFS_BLOCK_SIZE
>> 1;
592 if (logfile_is_empty
) {
593 NVolSetLogFileEmpty(vol
);
595 ntfs_log_trace("Done. ($LogFile is empty.)\n");
600 ntfs_log_error("BUG: rstr2_ph isn't NULL!\n");
601 ntfs_log_error("Did not find any restart pages in "
602 "$LogFile and it was not empty.\n");
605 /* If both restart pages were found, use the more recent one. */
608 * If the second restart area is more recent, switch to it.
609 * Otherwise just throw it away.
611 if (rstr2_lsn
> rstr1_lsn
) {
612 ntfs_log_debug("Using second restart page as it is more "
616 /* rstr1_lsn = rstr2_lsn; */
618 ntfs_log_debug("Using first restart page as it is more "
624 /* All consistency checks passed. */
629 ntfs_log_trace("Done.\n");
639 * ntfs_is_logfile_clean - check in the journal if the volume is clean
640 * @log_na: ntfs attribute of loaded journal $LogFile to check
641 * @rp: copy of the current restart page
643 * Analyze the $LogFile journal and return TRUE if it indicates the volume was
644 * shutdown cleanly and FALSE if not.
646 * At present we only look at the two restart pages and ignore the log record
647 * pages. This is a little bit crude in that there will be a very small number
648 * of cases where we think that a volume is dirty when in fact it is clean.
649 * This should only affect volumes that have not been shutdown cleanly but did
650 * not have any pending, non-check-pointed i/o, i.e. they were completely idle
651 * at least for the five seconds preceding the unclean shutdown.
653 * This function assumes that the $LogFile journal has already been consistency
654 * checked by a call to ntfs_check_logfile() and in particular if the $LogFile
655 * is empty this function requires that NVolLogFileEmpty() is true otherwise an
656 * empty volume will be reported as dirty.
658 BOOL
ntfs_is_logfile_clean(ntfs_attr
*log_na
, RESTART_PAGE_HEADER
*rp
)
662 ntfs_log_trace("Entering.\n");
663 /* An empty $LogFile must have been clean before it got emptied. */
664 if (NVolLogFileEmpty(log_na
->ni
->vol
)) {
665 ntfs_log_trace("$LogFile is empty\n");
669 ntfs_log_error("Restart page header is NULL\n");
672 if (!ntfs_is_rstr_record(rp
->magic
) &&
673 !ntfs_is_chkd_record(rp
->magic
)) {
674 ntfs_log_error("Restart page buffer is invalid\n");
678 ra
= (RESTART_AREA
*)((u8
*)rp
+ le16_to_cpu(rp
->restart_area_offset
));
680 * If the $LogFile has active clients, i.e. it is open, and we do not
681 * have the RESTART_VOLUME_IS_CLEAN bit set in the restart area flags,
682 * we assume there was an unclean shutdown.
684 if (ra
->client_in_use_list
!= LOGFILE_NO_CLIENT
&&
685 !(ra
->flags
& RESTART_VOLUME_IS_CLEAN
)) {
686 ntfs_log_error("The disk contains an unclean file system (%d, "
687 "%d).\n", le16_to_cpu(ra
->client_in_use_list
),
688 le16_to_cpu(ra
->flags
));
691 /* $LogFile indicates a clean shutdown. */
692 ntfs_log_trace("$LogFile indicates a clean shutdown\n");
697 * ntfs_empty_logfile - empty the contents of the $LogFile journal
698 * @na: ntfs attribute of journal $LogFile to empty
700 * Empty the contents of the $LogFile journal @na and return 0 on success and
703 * This function assumes that the $LogFile journal has already been consistency
704 * checked by a call to ntfs_check_logfile() and that ntfs_is_logfile_clean()
705 * has been used to ensure that the $LogFile is clean.
707 int ntfs_empty_logfile(ntfs_attr
*na
)
710 char buf
[NTFS_BUF_SIZE
];
712 ntfs_log_trace("Entering.\n");
714 if (NVolLogFileEmpty(na
->ni
->vol
))
717 if (!NAttrNonResident(na
)) {
719 ntfs_log_perror("Resident $LogFile $DATA attribute");
723 memset(buf
, -1, NTFS_BUF_SIZE
);
726 while ((count
= na
->data_size
- pos
) > 0) {
728 if (count
> NTFS_BUF_SIZE
)
729 count
= NTFS_BUF_SIZE
;
731 count
= ntfs_attr_pwrite(na
, pos
, count
, buf
);
733 ntfs_log_perror("Failed to reset $LogFile");
741 NVolSetLogFileEmpty(na
->ni
->vol
);