[xfs] Support XFS bigtime feature bit

Current version of mkfs.xfs enables this feature by default.
Now KolibriOS can read such partitions too.

git-svn-id: svn://kolibrios.org@9888 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2023-01-02 00:53:31 +00:00
parent 3e0d321fe1
commit df7f78788c
3 changed files with 68 additions and 41 deletions

View File

@ -682,8 +682,14 @@ struct HDLL
ends ends
struct DQ struct DQ
lo dd ? union
hi dd ? lo dd ?
hi_be dd ? ; big endian
ends
union
hi dd ?
lo_be dd ?
ends
ends ends
struct e820entry struct e820entry

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2013-2020. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2013-2022. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -161,6 +161,8 @@ proc xfs_create_partition uses ebx esi edi
and eax, XFS_SB_VERSION_NUMBITS and eax, XFS_SB_VERSION_NUMBITS
mov [edi+XFS.version], eax mov [edi+XFS.version], eax
mov [edi+XFS.conv_time_to_kos_epoch], xfs._.conv_time_to_kos_epoch
movbe eax, [ebx+xfs_sb.sb_features2] movbe eax, [ebx+xfs_sb.sb_features2]
mov [edi+XFS.features2], eax mov [edi+XFS.features2], eax
cmp [edi+XFS.version], 5 cmp [edi+XFS.version], 5
@ -198,6 +200,10 @@ proc xfs_create_partition uses ebx esi edi
mov [edi+XFS.dir_block_size], sizeof.xfs_dir3_data_hdr mov [edi+XFS.dir_block_size], sizeof.xfs_dir3_data_hdr
mov [edi+XFS.bmbt_block_size], sizeof.xfs_bmbt3_block mov [edi+XFS.bmbt_block_size], sizeof.xfs_bmbt3_block
mov [edi+XFS.da_blkinfo_size], sizeof.xfs_da3_blkinfo mov [edi+XFS.da_blkinfo_size], sizeof.xfs_da3_blkinfo
test [edi+XFS.features_incompat], XFS_SB_FEAT_INCOMPAT_BIGTIME
jz @f ; no bigtime
mov [edi+XFS.conv_time_to_kos_epoch], xfs._.conv_bigtime_to_kos_epoch
@@:
.vcommon: .vcommon:
movzx eax, [ebx+xfs_sb.sb_inodesize] movzx eax, [ebx+xfs_sb.sb_inodesize]
@ -1373,14 +1379,45 @@ proc xfs._.get_inode_number_sf
ret ret
endp endp
proc xfs._.conv_time_to_kos_epoch
movbe eax, [ecx+DQ.hi_be]
call fsTime2bdfe
ret
endp
proc xfs_get_inode_info uses ebx, _src, _dst proc xfs._.conv_bigtime_to_kos_epoch
NANOSEC_PER_SEC = 1_000_000_000
BIGTIME_TO_UNIX_OFFSET = 0x80000000 ; int32 min
UNIXTIME_TO_KOS_OFFSET = (365*31+8)*24*60*60 ; 01.01.1970--01.01.2001
BIGTIME_TO_KOS_OFFSET = BIGTIME_TO_UNIX_OFFSET + UNIXTIME_TO_KOS_OFFSET
BIGTIME_TO_KOS_OFFSET_NS = BIGTIME_TO_KOS_OFFSET * NANOSEC_PER_SEC
movbe edx, [ecx+DQ.hi_be]
movbe eax, [ecx+DQ.lo_be]
sub eax, BIGTIME_TO_KOS_OFFSET_NS AND 0xffffffff
sbb edx, BIGTIME_TO_KOS_OFFSET_NS SHR 32
jnc .after_kos_epoch_begin
xor eax, eax ; set to very begin of kolibrios epoch
xor edx, edx
jmp .time_to_bdfe
.after_kos_epoch_begin:
cmp edx, NANOSEC_PER_SEC
jb .time_to_bdfe
mov edx, NANOSEC_PER_SEC - 1
mov eax, -1 ; very end of kolibrios epoch
.time_to_bdfe:
mov ecx, NANOSEC_PER_SEC
div ecx
call fsTime2bdfe
ret
endp
proc xfs_get_inode_info uses ebx esi edi, _src, _dst
; get access time and other file properties ; get access time and other file properties
; useful for browsing directories ; useful for browsing directories
; called for each dir entry ; called for each dir entry
xor eax, eax xor eax, eax
mov edx, [_src] mov esi, [_src]
movzx ecx, [edx+xfs_inode.di_core.di_mode] movzx ecx, [esi+xfs_inode.di_core.di_mode]
xchg cl, ch xchg cl, ch
test ecx, S_IFDIR test ecx, S_IFDIR
jz @f jz @f
@ -1388,29 +1425,18 @@ proc xfs_get_inode_info uses ebx, _src, _dst
@@: @@:
mov edi, [_dst] mov edi, [_dst]
mov [edi+bdfe.attr], eax mov [edi+bdfe.attr], eax
movbe eax, [edx+xfs_inode.di_core.di_size.lo] movbe edx, [esi+xfs_inode.di_core.di_size.hi_be]
mov [edi+bdfe.size.hi], eax movbe eax, [esi+xfs_inode.di_core.di_size.lo_be]
movbe eax, [edx+xfs_inode.di_core.di_size.hi] mov [edi+bdfe.size.hi], edx
mov [edi+bdfe.size.lo], eax mov [edi+bdfe.size.lo], eax
add edi, 8 add edi, bdfe.ctime
movbe eax, [edx+xfs_inode.di_core.di_ctime.t_sec] lea ecx, [esi+xfs_inode.di_core.di_ctime]
push edx call [ebp+XFS.conv_time_to_kos_epoch]
sub eax, 978307200 ; 01.01.1970-01.01.2001 = (365*31+8)*24*60*60 lea ecx, [esi+xfs_inode.di_core.di_atime]
call fsTime2bdfe call [ebp+XFS.conv_time_to_kos_epoch]
pop edx lea ecx, [esi+xfs_inode.di_core.di_mtime]
call [ebp+XFS.conv_time_to_kos_epoch]
movbe eax, [edx+xfs_inode.di_core.di_atime.t_sec]
push edx
sub eax, 978307200 ; 01.01.1970-01.01.2001 = (365*31+8)*24*60*60
call fsTime2bdfe
pop edx
movbe eax, [edx+xfs_inode.di_core.di_mtime.t_sec]
push edx
sub eax, 978307200 ; 01.01.1970-01.01.2001 = (365*31+8)*24*60*60
call fsTime2bdfe
pop edx
movi eax, ERROR_SUCCESS movi eax, ERROR_SUCCESS
cmp esp, esp cmp esp, esp

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2013-2020. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2013-2022. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -86,9 +86,11 @@ XFS_SB_VERSION2_SUPPORTED = XFS_SB_VERSION2_LAZYSBCOUNTBIT OR \
XFS_SB_FEAT_INCOMPAT_FTYPE = 1 ; filetype in dirent XFS_SB_FEAT_INCOMPAT_FTYPE = 1 ; filetype in dirent
XFS_SB_FEAT_INCOMPAT_SPINODES = 2 ; sparse inode chunks XFS_SB_FEAT_INCOMPAT_SPINODES = 2 ; sparse inode chunks
XFS_SB_FEAT_INCOMPAT_META_UUID = 4 ; metadata UUID XFS_SB_FEAT_INCOMPAT_META_UUID = 4 ; metadata UUID
XFS_SB_FEAT_INCOMPAT_BIGTIME = 8 ; large timestamps
XFS_SB_FEAT_INCOMPAT_SUPPORTED = XFS_SB_FEAT_INCOMPAT_FTYPE OR \ XFS_SB_FEAT_INCOMPAT_SUPPORTED = XFS_SB_FEAT_INCOMPAT_FTYPE OR \
XFS_SB_FEAT_INCOMPAT_SPINODES OR \ XFS_SB_FEAT_INCOMPAT_SPINODES OR \
XFS_SB_FEAT_INCOMPAT_META_UUID XFS_SB_FEAT_INCOMPAT_META_UUID OR \
XFS_SB_FEAT_INCOMPAT_BIGTIME
; bitfield lengths for packed extent ; bitfield lengths for packed extent
; MSB to LSB / left to right ; MSB to LSB / left to right
@ -198,12 +200,6 @@ struct xfs_sb
sb_meta_uuid rb 16 ; metadata file system unique id sb_meta_uuid rb 16 ; metadata file system unique id
ends ends
; structure to store create, access and modification time in inode core
struct xfs_timestamp
t_sec dd ?
t_nsec dd ? ; nanoseconds
ends
; inode core structure: basic information about file ; inode core structure: basic information about file
struct xfs_dinode_core struct xfs_dinode_core
di_magic dw ? ; inode magic = XFS_DINODE_MAGIC di_magic dw ? ; inode magic = XFS_DINODE_MAGIC
@ -217,9 +213,9 @@ struct xfs_dinode_core
di_projid dw ? ; owner's project id di_projid dw ? ; owner's project id
di_pad rb 8 ; unused, zeroed space di_pad rb 8 ; unused, zeroed space
di_flushiter dw ? ; incremented on flush di_flushiter dw ? ; incremented on flush
di_atime xfs_timestamp ; time last accessed di_atime DQ ; time last accessed
di_mtime xfs_timestamp ; time last modified di_mtime DQ ; time last modified
di_ctime xfs_timestamp ; time created/inode modified di_ctime DQ ; time created/inode modified
di_size DQ ? ; number of bytes in file di_size DQ ? ; number of bytes in file
di_nblocks DQ ? ; number of direct & btree blocks used di_nblocks DQ ? ; number of direct & btree blocks used
di_extsize dd ? ; basic/minimum extent size for file di_extsize dd ? ; basic/minimum extent size for file
@ -243,7 +239,7 @@ struct xfs_dinode3_core xfs_dinode_core
di_pad2 rb 12 ; more padding for future expansion di_pad2 rb 12 ; more padding for future expansion
; fields only written to during inode creation ; fields only written to during inode creation
di_crtime xfs_timestamp ; time created di_crtime DQ ; time created
di_ino DQ ? ; inode number di_ino DQ ? ; inode number
di_uuid rb 16 ; UUID of the filesystem di_uuid rb 16 ; UUID of the filesystem
ends ends
@ -537,6 +533,7 @@ struct XFS PARTITION
dir_leafn_size dd ? dir_leafn_size dd ?
da_node_size dd ? da_node_size dd ?
da_blkinfo_size dd ? da_blkinfo_size dd ?
conv_time_to_kos_epoch dd ?
; helpers, temporary vars, etc ; helpers, temporary vars, etc
; should go to file descriptor and local vars? ; should go to file descriptor and local vars?
cur_block dd ? cur_block dd ?
@ -609,8 +606,6 @@ ends
struct bdfe struct bdfe
attr dd ? attr dd ?
nameenc dd ? nameenc dd ?
; nameenc db ?
; reserved db 3 dup(?)
ctime dd ? ctime dd ?
cdate dd ? cdate dd ?
atime dd ? atime dd ?