[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
struct DQ
lo dd ?
hi dd ?
union
lo dd ?
hi_be dd ? ; big endian
ends
union
hi dd ?
lo_be dd ?
ends
ends
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 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -161,6 +161,8 @@ proc xfs_create_partition uses ebx esi edi
and eax, XFS_SB_VERSION_NUMBITS
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]
mov [edi+XFS.features2], eax
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.bmbt_block_size], sizeof.xfs_bmbt3_block
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:
movzx eax, [ebx+xfs_sb.sb_inodesize]
@ -1373,14 +1379,45 @@ proc xfs._.get_inode_number_sf
ret
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
; useful for browsing directories
; called for each dir entry
xor eax, eax
mov edx, [_src]
movzx ecx, [edx+xfs_inode.di_core.di_mode]
mov esi, [_src]
movzx ecx, [esi+xfs_inode.di_core.di_mode]
xchg cl, ch
test ecx, S_IFDIR
jz @f
@ -1388,29 +1425,18 @@ proc xfs_get_inode_info uses ebx, _src, _dst
@@:
mov edi, [_dst]
mov [edi+bdfe.attr], eax
movbe eax, [edx+xfs_inode.di_core.di_size.lo]
mov [edi+bdfe.size.hi], eax
movbe eax, [edx+xfs_inode.di_core.di_size.hi]
movbe edx, [esi+xfs_inode.di_core.di_size.hi_be]
movbe eax, [esi+xfs_inode.di_core.di_size.lo_be]
mov [edi+bdfe.size.hi], edx
mov [edi+bdfe.size.lo], eax
add edi, 8
movbe eax, [edx+xfs_inode.di_core.di_ctime.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_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
add edi, bdfe.ctime
lea ecx, [esi+xfs_inode.di_core.di_ctime]
call [ebp+XFS.conv_time_to_kos_epoch]
lea ecx, [esi+xfs_inode.di_core.di_atime]
call [ebp+XFS.conv_time_to_kos_epoch]
lea ecx, [esi+xfs_inode.di_core.di_mtime]
call [ebp+XFS.conv_time_to_kos_epoch]
movi eax, ERROR_SUCCESS
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 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -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_SPINODES = 2 ; sparse inode chunks
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_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
; MSB to LSB / left to right
@ -198,12 +200,6 @@ struct xfs_sb
sb_meta_uuid rb 16 ; metadata file system unique id
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
struct xfs_dinode_core
di_magic dw ? ; inode magic = XFS_DINODE_MAGIC
@ -217,9 +213,9 @@ struct xfs_dinode_core
di_projid dw ? ; owner's project id
di_pad rb 8 ; unused, zeroed space
di_flushiter dw ? ; incremented on flush
di_atime xfs_timestamp ; time last accessed
di_mtime xfs_timestamp ; time last modified
di_ctime xfs_timestamp ; time created/inode modified
di_atime DQ ; time last accessed
di_mtime DQ ; time last modified
di_ctime DQ ; time created/inode modified
di_size DQ ? ; number of bytes in file
di_nblocks DQ ? ; number of direct & btree blocks used
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
; fields only written to during inode creation
di_crtime xfs_timestamp ; time created
di_crtime DQ ; time created
di_ino DQ ? ; inode number
di_uuid rb 16 ; UUID of the filesystem
ends
@ -537,6 +533,7 @@ struct XFS PARTITION
dir_leafn_size dd ?
da_node_size dd ?
da_blkinfo_size dd ?
conv_time_to_kos_epoch dd ?
; helpers, temporary vars, etc
; should go to file descriptor and local vars?
cur_block dd ?
@ -609,8 +606,6 @@ ends
struct bdfe
attr dd ?
nameenc dd ?
; nameenc db ?
; reserved db 3 dup(?)
ctime dd ?
cdate dd ?
atime dd ?