CASACURSOSESTUDANTESDOAÇÕESVÍDEOSEVENTOSTUTORIAISLINKSNOTÍCIACONTATO


VIDEOS 》 Linux Kernel FileSystems Subsystem

Refer:
File system :: https://en.wikipedia.org/wiki/File_system
-----
Linux Kernel Source:
/fs/filesystems.c :: http://elixir.free-electrons.com/linux/latest/source/fs/filesystems.c
register_filesystem(), unregister_filesystem() APIs :: http://elixir.free-electrons.com/linux/latest/source/fs/filesystems.c#L71
struct file_system_type data-structure :: http://elixir.free-electrons.com/linux/latest/source/include/linux/fs.h#L2068

Linux Kernel - ext4 filesystem type:
static struct file_system_type ext2_fs_type :: http://elixir.free-electrons.com/linux/latest/source/fs/ext4/super.c#L117
static struct file_system_type ext3_fs_type :: http://elixir.free-electrons.com/linux/latest/source/fs/ext4/super.c#L132
static struct file_system_type ext4_fs_type :: http://elixir.free-electrons.com/linux/latest/source/fs/ext4/super.c#L5774
static int __init ext4_init_fs(void) :: http://elixir.free-electrons.com/linux/latest/source/fs/ext4/super.c#L5786

Here is the register_filesystem(), unregister_filesystem() APIs (/fs/filesystems.c) from the Kernel-source version 4.14 for quick reference:

/**
 *	register_filesystem - register a new filesystem
 *	@fs: the file system structure
 *
 *	Adds the file system passed to the list of file systems the kernel
 *	is aware of for mount and other syscalls. Returns 0 on success,
 *	or a negative errno code on an error.
 *
 *	The &struct file_system_type that is passed is linked into the kernel 
 *	structures and must not be freed until the file system has been
 *	unregistered.
 */
 
int register_filesystem(struct file_system_type * fs)
{
	int res = 0;
	struct file_system_type ** p;

	BUG_ON(strchr(fs->name, '.'));
	if (fs->next)
		return -EBUSY;
	write_lock(&file_systems_lock);
	p = find_filesystem(fs->name, strlen(fs->name));
	if (*p)
		res = -EBUSY;
	else
		*p = fs;
	write_unlock(&file_systems_lock);
	return res;
}

EXPORT_SYMBOL(register_filesystem);

/**
 *	unregister_filesystem - unregister a file system
 *	@fs: filesystem to unregister
 *
 *	Remove a file system that was previously successfully registered
 *	with the kernel. An error is returned if the file system is not found.
 *	Zero is returned on a success.
 *	
 *	Once this function has returned the &struct file_system_type structure
 *	may be freed or reused.
 */
 
int unregister_filesystem(struct file_system_type * fs)
{
	struct file_system_type ** tmp;

	write_lock(&file_systems_lock);
	tmp = &file_systems;
	while (*tmp) {
		if (fs == *tmp) {
			*tmp = fs->next;
			fs->next = NULL;
			write_unlock(&file_systems_lock);
			synchronize_rcu();
			return 0;
		}
		tmp = &(*tmp)->next;
	}
	write_unlock(&file_systems_lock);

	return -EINVAL;
}

Here is the struct file_system_type data-structure (/include/linux/fs.h) from the Kernel-source version 4.14 for quick reference:

struct file_system_type {
	const char *name;
	int fs_flags;
#define FS_REQUIRES_DEV		1 
#define FS_BINARY_MOUNTDATA	2
#define FS_HAS_SUBTYPE		4
#define FS_USERNS_MOUNT		8	/* Can be mounted by userns root */
#define FS_RENAME_DOES_D_MOVE	32768	/* FS will handle d_move() during rename() internally. */
	struct dentry *(*mount) (struct file_system_type *, int,
		       const char *, void *);
	void (*kill_sb) (struct super_block *);
	struct module *owner;
	struct file_system_type * next;
	struct hlist_head fs_supers;

	struct lock_class_key s_lock_key;
	struct lock_class_key s_umount_key;
	struct lock_class_key s_vfs_rename_key;
	struct lock_class_key s_writers_key[SB_FREEZE_LEVELS];

	struct lock_class_key i_lock_key;
	struct lock_class_key i_mutex_key;
	struct lock_class_key i_mutex_dir_key;
};

Refer:
Linux Kernel Source:
/fs/inode.c :: http://elixir.free-electrons.com/linux/latest/source/fs/inode.c
struct inode :: http://elixir.free-electrons.com/linux/latest/source/include/linux/fs.h#L570

Linux Kernel - filesystem type specific inode handlers:
/fs/ext4/inode.c :: http://elixir.free-electrons.com/linux/latest/source/fs/ext4/inode.c
/fs/btrfs/inode.c :: http://elixir.free-electrons.com/linux/latest/source/fs/btrfs/inode.c
/fs/ext2/inode.c :: http://elixir.free-electrons.com/linux/latest/source/fs/ext2/inode.c

Here is the struct inode (/include/linux/fs.h) from the Kernel-source version 4.14 for quick reference:

struct inode {
	umode_t			i_mode;
	unsigned short		i_opflags;
	kuid_t			i_uid;
	kgid_t			i_gid;
	unsigned int		i_flags;

#ifdef CONFIG_FS_POSIX_ACL
	struct posix_acl	*i_acl;
	struct posix_acl	*i_default_acl;
#endif

	const struct inode_operations	*i_op;
	struct super_block	*i_sb;
	struct address_space	*i_mapping;

#ifdef CONFIG_SECURITY
	void			*i_security;
#endif

	/* Stat data, not accessed from path walking */
	unsigned long		i_ino;
	/*
	 * Filesystems may only read i_nlink directly.  They shall use the
	 * following functions for modification:
	 *
	 *    (set|clear|inc|drop)_nlink
	 *    inode_(inc|dec)_link_count
	 */
	union {
		const unsigned int i_nlink;
		unsigned int __i_nlink;
	};
	dev_t			i_rdev;
	loff_t			i_size;
	struct timespec		i_atime;
	struct timespec		i_mtime;
	struct timespec		i_ctime;
	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
	unsigned short          i_bytes;
	unsigned int		i_blkbits;
	enum rw_hint		i_write_hint;
	blkcnt_t		i_blocks;

#ifdef __NEED_I_SIZE_ORDERED
	seqcount_t		i_size_seqcount;
#endif

	/* Misc */
	unsigned long		i_state;
	struct rw_semaphore	i_rwsem;

	unsigned long		dirtied_when;	/* jiffies of first dirtying */
	unsigned long		dirtied_time_when;

	struct hlist_node	i_hash;
	struct list_head	i_io_list;	/* backing dev IO list */
#ifdef CONFIG_CGROUP_WRITEBACK
	struct bdi_writeback	*i_wb;		/* the associated cgroup wb */

	/* foreign inode detection, see wbc_detach_inode() */
	int			i_wb_frn_winner;
	u16			i_wb_frn_avg_time;
	u16			i_wb_frn_history;
#endif
	struct list_head	i_lru;		/* inode LRU list */
	struct list_head	i_sb_list;
	struct list_head	i_wb_list;	/* backing dev writeback list */
	union {
		struct hlist_head	i_dentry;
		struct rcu_head		i_rcu;
	};
	u64			i_version;
	atomic_t		i_count;
	atomic_t		i_dio_count;
	atomic_t		i_writecount;
#ifdef CONFIG_IMA
	atomic_t		i_readcount; /* struct files open RO */
#endif
	const struct file_operations	*i_fop;	/* former ->i_op->default_file_ops */
	struct file_lock_context	*i_flctx;
	struct address_space	i_data;
	struct list_head	i_devices;
	union {
		struct pipe_inode_info	*i_pipe;
		struct block_device	*i_bdev;
		struct cdev		*i_cdev;
		char			*i_link;
		unsigned		i_dir_seq;
	};

	__u32			i_generation;

#ifdef CONFIG_FSNOTIFY
	__u32			i_fsnotify_mask; /* all events this inode cares about */
	struct fsnotify_mark_connector __rcu	*i_fsnotify_marks;
#endif

#if IS_ENABLED(CONFIG_FS_ENCRYPTION)
	struct fscrypt_info	*i_crypt_info;
#endif

	void			*i_private; /* fs or device private pointer */
} __randomize_layout;

Refer:
Wiki:
Virtual file system :: https://en.wikipedia.org/wiki/Virtual_file_system
Linux Kernel Storage Stack Diagram :: https://upload.wikimedia.org/wikipedia/commons/3/30/IO_stack_of_the_Linux_kernel.svg
Image - Linux Virtual File System :: https://www.ibm.com/developerworks/library/l-virtual-filesystem-switch/figure2.gif


Wiki - Linux Kernel Storage Stack Diagram
Linux Kernel Storage Stack Diagram
Image - Linux Virtual File System
Image - Linux Virtual File System

Refer:
Wiki:
Virtual file system :: https://en.wikipedia.org/wiki/Virtual_file_system

Linux Kernel:
fs/namei.c - vfs_mknod(), vfs_mkdir(), vfs_rename() :: https://elixir.bootlin.com/linux/latest/source/fs/namei.c




Suggested Topics:


Video Episodes :: Linux Kernel programming

Linux Kernel - Containers and Namespaces ↗
Thursday' 09-Jul-2020

Linux Operating System - User-space Processes ↗
Thursday' 09-Jul-2020

Linux Kernel Architecture ↗
Thursday' 09-Jul-2020

Linux Kernel Programming ↗
Thursday' 09-Jul-2020

Linux Kernel FileSystems Subsystem ↗
Thursday' 09-Jul-2020

Linux Kernel Programming - Device Drivers ↗
Thursday' 09-Jul-2020
Watch detailed videos and read topics on Linux Kernel Programming - Device Drivers

Linux Kernel Compilation ↗
Thursday' 09-Jul-2020

Linux ioctl() API interface ↗
Thursday' 09-Jul-2020
Watch detailed videos and read topics on Linux Kernel Programming and Linux ioctl() API interface

Linux Kernel /proc Interface ↗
Thursday' 09-Jul-2020

Join The Linux Channel :: Facebook Group ↗

Visit The Linux Channel :: on Youtube ↗


Join a course:

💎 Linux, Kernel, Networking and Device Drivers: PDF Brochure
💎 PhD or equivalent (or Post Doctoral) looking for assistance: Details
💎 ... or unlimited life-time mentorship: Details


💗 Help shape the future: Sponsor/Donate


Tópicos recomendados:
Featured Video:
Assista no Youtube - [416//0] 0x170 How to verify NAS Rsync module tasks || FreeNAS NETGEAR ReadyNAS OpenMediaVault Rockstor UnRAID ↗

Roadmap - How to become Linux Kernel Developer - Device Drivers Programmer and a Systems Software Expert ↗
Thursday' 09-Jul-2020
Many viewers and even sometimes my students ask me how I can become a kernel programmer or just device driver developer and so on. So I shot this video (and an add-on video) where I summarized steps and a roadmap to become a full-fledged Linux Kernel Developer.

Compiling a C Compiler with a C Compilter | Compile gcc with gcc ↗
Thursday' 09-Jul-2020
The fundamental aspect of a programming language compiler is to translate code written from language to other. But most commonly compilers will compile code written in high-level human friendly language such as C, C++, Java, etc. to native CPU architecture specific (machine understandable) binary code which is nothing but sequence of CPU instructions. Hence if we see that way we should able to compile gcc Compiler source code with a gcc Compiler binary.

AT&T Archives: The UNIX Operating System ↗
Thursday' 09-Jul-2020

CEO, CTO Talk ↗
Thursday' 09-Jul-2020

Arduino UNO - RO Water Purifier Controller ↗
Thursday' 09-Jul-2020
Here is a Youtube VLOG of my DIY RO Water Purifier Controller done via Arduino UNO. I want the Arduino UNO to control the RO pump, so that it pumps for a specific duration and stops automatically. This is done via Opto-isolated 4 Channel 5V 10A Relay Board meant for Arduino UNO, Raspberry Pi or similar SoC boards which offers GPIO pins. To this relay I have connected the RO water purifier booster pump which works at 24V DC connected via 220V AC to 24V DC power supply adaptar. I have also connected a small active 5V buzzer to notify the progress and completion as it fills the tank/canister.

Programming Language Performance and Overheads ↗
Thursday' 09-Jul-2020
A detailed Youtube video series of various programming language performance and overheads - a big picture

CYRIL INGÉNIERIE - CoreFreq Linux CPU monitoring software ↗
Thursday' 09-Jul-2020

Nmap Network Scanning ↗
Thursday' 09-Jul-2020

Telnet installation and remote access ↗
Thursday' 09-Jul-2020

Linux Kernel Network Programming - Transport Layer L4 TCP/UDP Registration - Protocol APIs ↗
Thursday' 09-Jul-2020


Trending Video:
Assista no Youtube - [440//0] 0x169 Synchronization in Linux user-space - Architecting multi-process and multi-threads ↗

Linux Kernel Networking Sub-system ↗
Thursday' 09-Jul-2020



Recommended Video:
Assista no Youtube - [174//0] 0x9 FreeBSD Networking Sub-system | Layer2 Bridging Stack | Design, APIs and Data-structures | Ep4 ↗