Skip to content

Commit fd986c2

Browse files
committed
tarfs: introduce tar fs
It is a file system based on tar files and an index appended to them (to facilitate finding fs entries without having to traverse the whole tar file). Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
1 parent a3bfef4 commit fd986c2

File tree

7 files changed

+429
-1
lines changed

7 files changed

+429
-1
lines changed

fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ source "fs/sysv/Kconfig"
331331
source "fs/ufs/Kconfig"
332332
source "fs/erofs/Kconfig"
333333
source "fs/vboxsf/Kconfig"
334+
source "fs/tarfs/Kconfig"
334335

335336
endif # MISC_FILESYSTEMS
336337

fs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,4 @@ obj-$(CONFIG_EFIVAR_FS) += efivarfs/
129129
obj-$(CONFIG_EROFS_FS) += erofs/
130130
obj-$(CONFIG_VBOXSF_FS) += vboxsf/
131131
obj-$(CONFIG_ZONEFS_FS) += zonefs/
132+
obj-$(CONFIG_TARFS_FS) += tarfs/

fs/tarfs/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
4+
config TARFS_FS
5+
tristate "TAR file system support"
6+
depends on RUST && BLOCK
7+
select BUFFER_HEAD
8+
help
9+
This is a simple read-only file system intended for mounting
10+
tar files that have had an index appened to them.
11+
12+
To compile this file system support as a module, choose M here: the
13+
module will be called tarfs.
14+
15+
If you don't know whether you need it, then you don't need it:
16+
answer N.

fs/tarfs/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Makefile for the linux tarfs filesystem routines.
4+
#
5+
6+
obj-$(CONFIG_TARFS_FS) += tarfs.o
7+
8+
tarfs-y := tar.o

fs/tarfs/defs.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
//! Definitions of tarfs structures.
4+
5+
use kernel::types::LE;
6+
7+
/// Flags used in [`Inode::flags`].
8+
pub mod inode_flags {
9+
/// Indicates that the inode is opaque.
10+
///
11+
/// When set, inode will have the "trusted.overlay.opaque" set to "y" at runtime.
12+
pub const OPAQUE: u8 = 0x1;
13+
}
14+
15+
kernel::derive_readable_from_bytes! {
16+
/// An inode in the tarfs inode table.
17+
#[repr(C)]
18+
pub struct Inode {
19+
/// The mode of the inode.
20+
///
21+
/// The bottom 9 bits are the rwx bits for owner, group, all.
22+
///
23+
/// The bits in the [`S_IFMT`] mask represent the file mode.
24+
pub mode: LE<u16>,
25+
26+
/// Tarfs flags for the inode.
27+
///
28+
/// Values are drawn from the [`inode_flags`] module.
29+
pub flags: u8,
30+
31+
/// The bottom 4 bits represent the top 4 bits of mtime.
32+
pub hmtime: u8,
33+
34+
/// The owner of the inode.
35+
pub owner: LE<u32>,
36+
37+
/// The group of the inode.
38+
pub group: LE<u32>,
39+
40+
/// The bottom 32 bits of mtime.
41+
pub lmtime: LE<u32>,
42+
43+
/// Size of the contents of the inode.
44+
pub size: LE<u64>,
45+
46+
/// Either the offset to the data, or the major and minor numbers of a device.
47+
///
48+
/// For the latter, the 32 LSB are the minor, and the 32 MSB are the major numbers.
49+
pub offset: LE<u64>,
50+
}
51+
52+
/// An entry in a tarfs directory entry table.
53+
#[repr(C)]
54+
pub struct DirEntry {
55+
/// The inode number this entry refers to.
56+
pub ino: LE<u64>,
57+
58+
/// The offset to the name of the entry.
59+
pub name_offset: LE<u64>,
60+
61+
/// The length of the name of the entry.
62+
pub name_len: LE<u64>,
63+
64+
/// The type of entry.
65+
pub etype: u8,
66+
67+
/// Unused padding.
68+
pub _padding: [u8; 7],
69+
}
70+
71+
/// The super-block of a tarfs instance.
72+
#[repr(C)]
73+
pub struct Header {
74+
/// The offset to the beginning of the inode-table.
75+
pub inode_table_offset: LE<u64>,
76+
77+
/// The number of inodes in the file system.
78+
pub inode_count: LE<u64>,
79+
}
80+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy