SlideShare ist ein Scribd-Unternehmen logo
1 von 89
Downloaden Sie, um offline zu lesen
Sabato 24 Ottobre 2015
#LDROMA15
http://lug.uniroma2.it/ld15/
All'ombra del
Leviatano
https://robertoreale.me/linux-day-2015
File e filesystem
Die Dataien hat der liebe Gott gemacht, alles andere ist
Menschenwerk.
Source: Leopold Kronecker (apocrifo)
file is the new byte
All files are created equal.
Source: Anonimo
Everything is a file.
Source: Anonimo
All file systems are not created equal.
Source: 11th USENIX Symposium on Operating Systems Design and Implementation
(OSDI 14)
Fondazioni
For most users, the filesystem is the most visible
aspect of an operating system.
Source: Silberschatz & Galvin, Operating System Concepts, 7th ed.
The filesystem consists of two distinct parts: a collection
of files, each storing related data, and a directory
structure, which organizes and provides information about
all the files in the system.
Source: Silberschatz & Galvin, Operating System Concepts, 7th ed.
The most important job of UNIX is to provide a filesystem.
Source: Ritchie & Thompson, The UNIX TimeSharing System
A file contains whatever information the user places on it, for
example symbolic or binary (object) programs.
No particular structuring is expected by the
system.
Source: Ritchie & Thompson, The UNIX TimeSharing System
A file does not exist within a particular directory; the directory
entry for a file consists merely of its name and a pointer to the
information actually describing the file.
Source: Ritchie & Thompson, The UNIX TimeSharing System
There is a threefold advantage in treating I/O devices this way:
file and device I/O are as similar as possible; file and device
names have the same syntax and meaning, so that a program
expecting a file name as a parameter can be passed a device
name; finally, special files are subject to the same protection
mechanism as regular files.
Source: Ritchie & Thompson, The UNIX TimeSharing System
Perhaps paradoxically, the success of UNIX is largely due to
the fact that it was not designed to meet any predefined
objectives.
Source: Ritchie & Thompson, The UNIX TimeSharing System
Precisazioni
The whole point with "everything is a file" is not that you have
some random filename, but the fact that you can use
common tools to operate on different things.
Source: Linux Torvalds, 8 giugno 2002
The UNIX philosophy is often quoted as "everything is a file",
but that really means everything is a stream of
bytes.
Source: Linux Torvalds, 8 marzo 2007
It should be just a "read()", and then people can use
general libraries and treat all sources the
same.
Source: Linux Torvalds, 8 marzo 2007
Il paradosso
everything is a file
ma
il perimetro di cosa è un file non è flessible ad libitum
il perimetro di cosa è un file è
fissato dal kernel
la sintassi e la semantica del filesystem sono fissate dal
kernel
Il Leviatano
VFS: oltre 65 mila righe di codice già nel 2008
Source: Galloway et al., Model-Checking the Linux Virtual File System
approccio conservativo
kernel-centrico
debug difficile
l'utente non amministratore semplicemente non può
ecce spes eius frustrabitur eum et videntibus cunctis
praecipitabitur
Source: Iob, 41, 1
VFS
Astrazione
File: modello comune
Strutture dati: superblock, inode, file, dentry
Operazioni
Object-oriented
Implementazione
Disk data structures
Memory data structures
Disk space management
Precursori
Earlier VFS implementations include Sun's VFS (in SunOS
version 2.0, circa 1985) and IBM and Microsoft's "Installable
File System" for IBM OS/2.
Source: M. Tim Jones, Anatomy of the Linux virtual filesystem switch
Altre strade
Synthetic Files
9P: Plan 9 Filesystem Protocol
puffs: Pass-to-Userspace Framework File System su NetBSD
A filesystem is a protocol translator: it interprets incoming
requests and transforms them into a form suitable to store and
retrieve data.
Source: Antti Kantee, Send and Receive of File System Protocols
Hurd translators
A translator is simply a normal program acting as an object
server and participating in the Hurd's distributed virtual
filesystem.
Source: https://www.gnu.org/software/hurd/hurd/translator.html
It is so-called because it typically exports a filesystem
(although need not: cf. auth, proc and pfinet) and thus
translates object invocations into calls appropriate for the
backing store (e.g., ext2 filesystem, nfs server, etc.).
Source: https://www.gnu.org/software/hurd/hurd/translator.html
Another way of putting it is that it translates from one
representation of a data structure into another representation,
for example from the on-disk ext2 data layout to a traditional
filesystem hierarchy, or from a XML file to a virtual
hierarchical manifestation.
Source: https://www.gnu.org/software/hurd/hurd/translator.html
A translator is usually registered with a specific filesystem
node by using the settrans command.
Source: https://www.gnu.org/software/hurd/hurd/translator.html
Translators do not require any special privilege to run. The
privilege they require is simply that to access the indiviudal
resources they use.
Source: https://www.gnu.org/software/hurd/hurd/translator.html
FUSE
Filesystem in
Userspace
With FUSE it is possible to implement a fully functional
filesystem in a userspace program.
Source: http://fuse.sourceforge.net/
Autore Miklos Szeredi
Licenze GPL + LGPL
Features include...
simple library API
simple installation (no need to patch or recompile the kernel)
secure implementation
userspace-kernel interface is very efficient
usable by non privileged users
Source: http://fuse.sourceforge.net/
Interazione attraverso un file (ancora!): /dev/fuse.
FUSE is a userspace filesystem framework. It consists of a
kernel module (fuse.ko), a userspace library (libfuse.*) and a
mount utility (fusermount).
Source: http://fuse.sourceforge.net/doxygen/index.html
One of the most important features of FUSE is allowing
secure, non-privileged mounts. This opens up new possibilities
for the use of filesystems. A good example is sshfs: a secure
network filesystem using the sftp protocol.
Source: http://fuse.sourceforge.net/doxygen/index.html
Since the mount() system call is a privileged operation, a
helper program (fusermount) is needed, which is installed
setuid root.
Source: http://fuse.sourceforge.net/doxygen/index.html
Vocabolario
Userspace filesystem
A filesystem in which data and metadata are provided by an
ordinary userspace process. The filesystem can be accessed
normally through the kernel interface.
Source: http://fuse.sourceforge.net/doxygen/index.html
Filesystem daemon
The process(es) providing the data and metadata of the
filesystem.
Source: http://fuse.sourceforge.net/doxygen/index.html
Non-privileged mount (or user mount)
A userspace filesystem mounted by a non-privileged (non-
root) user. The filesystem daemon is running with the
privileges of the mounting user.
Source: http://fuse.sourceforge.net/doxygen/index.html
Filesystem connection
A connection between the filesystem daemon and the kernel.
The connection exists until either the daemon dies, or the
filesystem is umounted.
Source: http://fuse.sourceforge.net/doxygen/index.html
Mount owner
The user who does the mounting.
Source: http://fuse.sourceforge.net/doxygen/index.html
User
The user who is performing filesystem operations.
Source: http://fuse.sourceforge.net/doxygen/index.html
hello.c
/*
FUSE: Filesystem in Userspace
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
*/
#define FUSE_USE_VERSION 30
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
static const char *hello_str = "Hello World!n";
static const char *hello_path = "/hello";
static int hello_getattr(const char *path, struct stat *stbuf)
{
int res = 0;
memset(stbuf, 0, sizeof(struct stat));
if (strcmp(path, "/") == 0) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 2;
} else if (strcmp(path, hello_path) == 0) {
stbuf->st_mode = S_IFREG | 0444;
stbuf->st_nlink = 1;
stbuf->st_size = strlen(hello_str);
} else
res = -ENOENT;
return res;
}
static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
(void) offset;
(void) fi;
if (strcmp(path, "/") != 0)
return -ENOENT;
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, hello_path + 1, NULL, 0);
return 0;
}
static int hello_open(const char *path, struct fuse_file_info *fi)
{
if (strcmp(path, hello_path) != 0)
return -ENOENT;
if ((fi->flags & 3) != O_RDONLY)
return -EACCES;
return 0;
}
static int hello_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
size_t len;
(void) fi;
if(strcmp(path, hello_path) != 0)
return -ENOENT;
len = strlen(hello_str);
if (offset < len) {
if (offset + size > len)
size = len - offset;
memcpy(buf, hello_str + offset, size);
} else
size = 0;
return size;
}
static struct fuse_operations hello_oper = {
.getattr = hello_getattr,
.readdir = hello_readdir,
.open = hello_open,
.read = hello_read,
};
int main(int argc, char *argv[])
{
return fuse_main(argc, argv, &hello_oper, NULL);
}
Bestiario
CephFS
FUSE come vivaio, come coltura di giovani filesystem.
CephFS è nel kernel dalla versione 2.6.34.
Couchfuse
Couchfuse is a FUSE filesystem that exposes Couchdb
databases as filesystem folder.
Source: http://narkisr.github.io/couch-fuse/
elfs
A simple (FUSE) filesystem on top of ELF objects.
Autore: Guillaume Leconte
Source: https://github.com/pozdnychev/elfs
$ elfs `which fdup` /tmp/elf
$ ls -l /tmp/elf/
total 0
drw-r--r-- 1 root root 0 Jan 1 1970 header
drw-r--r-- 1 root root 0 Jan 1 1970 libs
drw-r--r-- 1 root root 0 Jan 1 1970 sections
estensione ad altri formati binari
astrazione dal formato
interfaccia verso exec()
etcd-fs
A replicated filesystem on top of etcd.
Autore: Jonathan Leibiusky
Source: https://github.com/xetorthio/etcd-fs
fusepy
Simple ctypes bindings for FUSE.
Autore: Terence Honles
Source: https://github.com/fusepy/fusepy
GlusterFS
GlusterFS is a scalable network filesystem. Using common
off-the-shelf hardware, you can create large, distributed
storage solutions for media streaming, data analysis, and other
data- and bandwidth-intensive tasks.
Source: http://www.gluster.org/
PNGdrive
PNG meets Steganography meets Fuse: the easiest way to have
plausible deniability.
Source: https://code.google.com/p/pngdrive/
WikipediaFS
WikipediaFS is a virtual filesystem which allows users to view
and edit Wikipedia articles as if they were real files on a local
disk drive.
Source: https://en.wikipedia.org/wiki/WikipediaFS
Colofóne
Presentazione composta con vim e Hovercraft! su Ubuntu Saucy.
Featuring Google Fonts: Libre Baskerville, Racing Sans One,
Satisfy.
exit()
Roberto Reale
https://robertoreale.me/linux-day-2015

Weitere ähnliche Inhalte

Was ist angesagt?

Unit 3
Unit  3Unit  3
Unit 3siddr
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsDivye Kapoor
 
Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Martijn Verburg
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04spDr.Ravi
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)anandvaidya
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsTushar B Kute
 
Desktop Forensics: Windows
Desktop Forensics: WindowsDesktop Forensics: Windows
Desktop Forensics: WindowsGol D Roger
 
Useful linux-commands
Useful linux-commandsUseful linux-commands
Useful linux-commandsHimani Singh
 
Perl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File ProcessingPerl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File ProcessingDanairat Thanabodithammachari
 
AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!Zubair Nabi
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!Zubair Nabi
 
Programming in C Session 4
Programming in C Session 4Programming in C Session 4
Programming in C Session 4Prerna Sharma
 
Concept of file handling in c
Concept of file handling in cConcept of file handling in c
Concept of file handling in cMugdhaSharma11
 

Was ist angesagt? (18)

Unit 3
Unit  3Unit  3
Unit 3
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
Unit 5 dwqb ans
Unit 5 dwqb ansUnit 5 dwqb ans
Unit 5 dwqb ans
 
Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix Threads
 
Desktop Forensics: Windows
Desktop Forensics: WindowsDesktop Forensics: Windows
Desktop Forensics: Windows
 
Useful linux-commands
Useful linux-commandsUseful linux-commands
Useful linux-commands
 
Perl Programming - 03 Programming File
Perl Programming - 03 Programming FilePerl Programming - 03 Programming File
Perl Programming - 03 Programming File
 
File handling in C
File handling in CFile handling in C
File handling in C
 
Perl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File ProcessingPerl for System Automation - 01 Advanced File Processing
Perl for System Automation - 01 Advanced File Processing
 
AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!
 
File handling in c
File  handling in cFile  handling in c
File handling in c
 
Programming in C Session 4
Programming in C Session 4Programming in C Session 4
Programming in C Session 4
 
Concept of file handling in c
Concept of file handling in cConcept of file handling in c
Concept of file handling in c
 

Ähnlich wie Everything is a file with FUSE

Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure amol_chavan
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemSadia Bashir
 
MODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptxMODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptxManasaPJ1
 
18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptx18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptxChenamPawan
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentalsRaghu nath
 
Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)hildenjohannes
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device driversAlexandre Moreno
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338Cam YP Co., Ltd
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338Cam YP Co., Ltd
 
linuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdflinuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdfShaswatSurya
 

Ähnlich wie Everything is a file with FUSE (20)

Unix-module3.pptx
Unix-module3.pptxUnix-module3.pptx
Unix-module3.pptx
 
Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
Host security
Host securityHost security
Host security
 
Host security
Host securityHost security
Host security
 
MODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptxMODULE 3.1 updated-18cs56.pptx
MODULE 3.1 updated-18cs56.pptx
 
File management
File managementFile management
File management
 
18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptx18CS56-UP-Module 3.pptx
18CS56-UP-Module 3.pptx
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
Operating system
Operating systemOperating system
Operating system
 
Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
Tutorial 2
Tutorial 2Tutorial 2
Tutorial 2
 
Linux
LinuxLinux
Linux
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 
Linux file system
Linux file systemLinux file system
Linux file system
 
linuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdflinuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdf
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 

Mehr von Roberto Reale

eInvoicing adoption in Italy & CEF projects
eInvoicing adoption in Italy & CEF projectseInvoicing adoption in Italy & CEF projects
eInvoicing adoption in Italy & CEF projectsRoberto Reale
 
eProcurement governance: i nodi da sciogliere
eProcurement governance: i nodi da sciogliereeProcurement governance: i nodi da sciogliere
eProcurement governance: i nodi da sciogliereRoberto Reale
 
Governing Information Security
Governing Information SecurityGoverning Information Security
Governing Information SecurityRoberto Reale
 
Società Civile: diritto di accesso e sicurezza in rete
Società Civile: diritto di accesso e sicurezza in reteSocietà Civile: diritto di accesso e sicurezza in rete
Società Civile: diritto di accesso e sicurezza in reteRoberto Reale
 
Tecnologie emergenti: opportunità, sfide, governance
Tecnologie emergenti: opportunità, sfide, governanceTecnologie emergenti: opportunità, sfide, governance
Tecnologie emergenti: opportunità, sfide, governanceRoberto Reale
 
Blockchain for Business
Blockchain for BusinessBlockchain for Business
Blockchain for BusinessRoberto Reale
 
Politically correct. Sentiment analysis of Italian political texts
Politically correct. Sentiment analysis of Italian political textsPolitically correct. Sentiment analysis of Italian political texts
Politically correct. Sentiment analysis of Italian political textsRoberto Reale
 
Beyond relational: «neural» DBMS?
Beyond relational: «neural» DBMS?Beyond relational: «neural» DBMS?
Beyond relational: «neural» DBMS?Roberto Reale
 
La Strategia per la Crescita Digitale 2014-2020
La Strategia per la Crescita Digitale 2014-2020La Strategia per la Crescita Digitale 2014-2020
La Strategia per la Crescita Digitale 2014-2020Roberto Reale
 
Homo Digitalis: Metamorfosi dell'identità
Homo Digitalis: Metamorfosi dell'identitàHomo Digitalis: Metamorfosi dell'identità
Homo Digitalis: Metamorfosi dell'identitàRoberto Reale
 
The History of Technological Anxiety and the Future of Economic Growth: Is Th...
The History of Technological Anxiety and the Future of Economic Growth: Is Th...The History of Technological Anxiety and the Future of Economic Growth: Is Th...
The History of Technological Anxiety and the Future of Economic Growth: Is Th...Roberto Reale
 
Fog and the City: an urbanist's perspective
Fog and the City: an urbanist's perspectiveFog and the City: an urbanist's perspective
Fog and the City: an urbanist's perspectiveRoberto Reale
 
The Unbearable Lightness: Extending the Bash shell
The Unbearable Lightness: Extending the Bash shellThe Unbearable Lightness: Extending the Bash shell
The Unbearable Lightness: Extending the Bash shellRoberto Reale
 

Mehr von Roberto Reale (13)

eInvoicing adoption in Italy & CEF projects
eInvoicing adoption in Italy & CEF projectseInvoicing adoption in Italy & CEF projects
eInvoicing adoption in Italy & CEF projects
 
eProcurement governance: i nodi da sciogliere
eProcurement governance: i nodi da sciogliereeProcurement governance: i nodi da sciogliere
eProcurement governance: i nodi da sciogliere
 
Governing Information Security
Governing Information SecurityGoverning Information Security
Governing Information Security
 
Società Civile: diritto di accesso e sicurezza in rete
Società Civile: diritto di accesso e sicurezza in reteSocietà Civile: diritto di accesso e sicurezza in rete
Società Civile: diritto di accesso e sicurezza in rete
 
Tecnologie emergenti: opportunità, sfide, governance
Tecnologie emergenti: opportunità, sfide, governanceTecnologie emergenti: opportunità, sfide, governance
Tecnologie emergenti: opportunità, sfide, governance
 
Blockchain for Business
Blockchain for BusinessBlockchain for Business
Blockchain for Business
 
Politically correct. Sentiment analysis of Italian political texts
Politically correct. Sentiment analysis of Italian political textsPolitically correct. Sentiment analysis of Italian political texts
Politically correct. Sentiment analysis of Italian political texts
 
Beyond relational: «neural» DBMS?
Beyond relational: «neural» DBMS?Beyond relational: «neural» DBMS?
Beyond relational: «neural» DBMS?
 
La Strategia per la Crescita Digitale 2014-2020
La Strategia per la Crescita Digitale 2014-2020La Strategia per la Crescita Digitale 2014-2020
La Strategia per la Crescita Digitale 2014-2020
 
Homo Digitalis: Metamorfosi dell'identità
Homo Digitalis: Metamorfosi dell'identitàHomo Digitalis: Metamorfosi dell'identità
Homo Digitalis: Metamorfosi dell'identità
 
The History of Technological Anxiety and the Future of Economic Growth: Is Th...
The History of Technological Anxiety and the Future of Economic Growth: Is Th...The History of Technological Anxiety and the Future of Economic Growth: Is Th...
The History of Technological Anxiety and the Future of Economic Growth: Is Th...
 
Fog and the City: an urbanist's perspective
Fog and the City: an urbanist's perspectiveFog and the City: an urbanist's perspective
Fog and the City: an urbanist's perspective
 
The Unbearable Lightness: Extending the Bash shell
The Unbearable Lightness: Extending the Bash shellThe Unbearable Lightness: Extending the Bash shell
The Unbearable Lightness: Extending the Bash shell
 

Kürzlich hochgeladen

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 

Kürzlich hochgeladen (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 

Everything is a file with FUSE

  • 1. Sabato 24 Ottobre 2015 #LDROMA15 http://lug.uniroma2.it/ld15/
  • 5. Die Dataien hat der liebe Gott gemacht, alles andere ist Menschenwerk. Source: Leopold Kronecker (apocrifo)
  • 6. file is the new byte
  • 7. All files are created equal. Source: Anonimo
  • 8. Everything is a file. Source: Anonimo
  • 9. All file systems are not created equal. Source: 11th USENIX Symposium on Operating Systems Design and Implementation (OSDI 14)
  • 11. For most users, the filesystem is the most visible aspect of an operating system. Source: Silberschatz & Galvin, Operating System Concepts, 7th ed.
  • 12. The filesystem consists of two distinct parts: a collection of files, each storing related data, and a directory structure, which organizes and provides information about all the files in the system. Source: Silberschatz & Galvin, Operating System Concepts, 7th ed.
  • 13. The most important job of UNIX is to provide a filesystem. Source: Ritchie & Thompson, The UNIX TimeSharing System
  • 14. A file contains whatever information the user places on it, for example symbolic or binary (object) programs. No particular structuring is expected by the system. Source: Ritchie & Thompson, The UNIX TimeSharing System
  • 15. A file does not exist within a particular directory; the directory entry for a file consists merely of its name and a pointer to the information actually describing the file. Source: Ritchie & Thompson, The UNIX TimeSharing System
  • 16. There is a threefold advantage in treating I/O devices this way: file and device I/O are as similar as possible; file and device names have the same syntax and meaning, so that a program expecting a file name as a parameter can be passed a device name; finally, special files are subject to the same protection mechanism as regular files. Source: Ritchie & Thompson, The UNIX TimeSharing System
  • 17. Perhaps paradoxically, the success of UNIX is largely due to the fact that it was not designed to meet any predefined objectives. Source: Ritchie & Thompson, The UNIX TimeSharing System
  • 19. The whole point with "everything is a file" is not that you have some random filename, but the fact that you can use common tools to operate on different things. Source: Linux Torvalds, 8 giugno 2002
  • 20. The UNIX philosophy is often quoted as "everything is a file", but that really means everything is a stream of bytes. Source: Linux Torvalds, 8 marzo 2007
  • 21. It should be just a "read()", and then people can use general libraries and treat all sources the same. Source: Linux Torvalds, 8 marzo 2007
  • 23. everything is a file ma il perimetro di cosa è un file non è flessible ad libitum
  • 24. il perimetro di cosa è un file è fissato dal kernel
  • 25. la sintassi e la semantica del filesystem sono fissate dal kernel
  • 27. VFS: oltre 65 mila righe di codice già nel 2008 Source: Galloway et al., Model-Checking the Linux Virtual File System
  • 30. l'utente non amministratore semplicemente non può
  • 31. ecce spes eius frustrabitur eum et videntibus cunctis praecipitabitur Source: Iob, 41, 1
  • 32. VFS
  • 33. Astrazione File: modello comune Strutture dati: superblock, inode, file, dentry Operazioni Object-oriented
  • 34. Implementazione Disk data structures Memory data structures Disk space management
  • 35. Precursori Earlier VFS implementations include Sun's VFS (in SunOS version 2.0, circa 1985) and IBM and Microsoft's "Installable File System" for IBM OS/2. Source: M. Tim Jones, Anatomy of the Linux virtual filesystem switch
  • 38. 9P: Plan 9 Filesystem Protocol
  • 39. puffs: Pass-to-Userspace Framework File System su NetBSD
  • 40. A filesystem is a protocol translator: it interprets incoming requests and transforms them into a form suitable to store and retrieve data. Source: Antti Kantee, Send and Receive of File System Protocols
  • 42. A translator is simply a normal program acting as an object server and participating in the Hurd's distributed virtual filesystem. Source: https://www.gnu.org/software/hurd/hurd/translator.html
  • 43. It is so-called because it typically exports a filesystem (although need not: cf. auth, proc and pfinet) and thus translates object invocations into calls appropriate for the backing store (e.g., ext2 filesystem, nfs server, etc.). Source: https://www.gnu.org/software/hurd/hurd/translator.html
  • 44. Another way of putting it is that it translates from one representation of a data structure into another representation, for example from the on-disk ext2 data layout to a traditional filesystem hierarchy, or from a XML file to a virtual hierarchical manifestation. Source: https://www.gnu.org/software/hurd/hurd/translator.html
  • 45. A translator is usually registered with a specific filesystem node by using the settrans command. Source: https://www.gnu.org/software/hurd/hurd/translator.html
  • 46. Translators do not require any special privilege to run. The privilege they require is simply that to access the indiviudal resources they use. Source: https://www.gnu.org/software/hurd/hurd/translator.html
  • 48.
  • 49. With FUSE it is possible to implement a fully functional filesystem in a userspace program. Source: http://fuse.sourceforge.net/
  • 53. simple installation (no need to patch or recompile the kernel)
  • 56. usable by non privileged users Source: http://fuse.sourceforge.net/
  • 57. Interazione attraverso un file (ancora!): /dev/fuse.
  • 58. FUSE is a userspace filesystem framework. It consists of a kernel module (fuse.ko), a userspace library (libfuse.*) and a mount utility (fusermount). Source: http://fuse.sourceforge.net/doxygen/index.html
  • 59. One of the most important features of FUSE is allowing secure, non-privileged mounts. This opens up new possibilities for the use of filesystems. A good example is sshfs: a secure network filesystem using the sftp protocol. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 60. Since the mount() system call is a privileged operation, a helper program (fusermount) is needed, which is installed setuid root. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 62. Userspace filesystem A filesystem in which data and metadata are provided by an ordinary userspace process. The filesystem can be accessed normally through the kernel interface. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 63. Filesystem daemon The process(es) providing the data and metadata of the filesystem. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 64. Non-privileged mount (or user mount) A userspace filesystem mounted by a non-privileged (non- root) user. The filesystem daemon is running with the privileges of the mounting user. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 65. Filesystem connection A connection between the filesystem daemon and the kernel. The connection exists until either the daemon dies, or the filesystem is umounted. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 66. Mount owner The user who does the mounting. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 67. User The user who is performing filesystem operations. Source: http://fuse.sourceforge.net/doxygen/index.html
  • 69. /* FUSE: Filesystem in Userspace Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> This program can be distributed under the terms of the GNU GPL. See the file COPYING. */ #define FUSE_USE_VERSION 30 #include <fuse.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <fcntl.h> static const char *hello_str = "Hello World!n"; static const char *hello_path = "/hello";
  • 70. static int hello_getattr(const char *path, struct stat *stbuf) { int res = 0; memset(stbuf, 0, sizeof(struct stat)); if (strcmp(path, "/") == 0) { stbuf->st_mode = S_IFDIR | 0755; stbuf->st_nlink = 2; } else if (strcmp(path, hello_path) == 0) { stbuf->st_mode = S_IFREG | 0444; stbuf->st_nlink = 1; stbuf->st_size = strlen(hello_str); } else res = -ENOENT; return res; }
  • 71. static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { (void) offset; (void) fi; if (strcmp(path, "/") != 0) return -ENOENT; filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); filler(buf, hello_path + 1, NULL, 0); return 0; }
  • 72. static int hello_open(const char *path, struct fuse_file_info *fi) { if (strcmp(path, hello_path) != 0) return -ENOENT; if ((fi->flags & 3) != O_RDONLY) return -EACCES; return 0; }
  • 73. static int hello_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { size_t len; (void) fi; if(strcmp(path, hello_path) != 0) return -ENOENT; len = strlen(hello_str); if (offset < len) { if (offset + size > len) size = len - offset; memcpy(buf, hello_str + offset, size); } else size = 0; return size; }
  • 74. static struct fuse_operations hello_oper = { .getattr = hello_getattr, .readdir = hello_readdir, .open = hello_open, .read = hello_read, };
  • 75. int main(int argc, char *argv[]) { return fuse_main(argc, argv, &hello_oper, NULL); }
  • 77. CephFS FUSE come vivaio, come coltura di giovani filesystem. CephFS è nel kernel dalla versione 2.6.34.
  • 78. Couchfuse Couchfuse is a FUSE filesystem that exposes Couchdb databases as filesystem folder. Source: http://narkisr.github.io/couch-fuse/
  • 79. elfs A simple (FUSE) filesystem on top of ELF objects. Autore: Guillaume Leconte Source: https://github.com/pozdnychev/elfs
  • 80. $ elfs `which fdup` /tmp/elf $ ls -l /tmp/elf/ total 0 drw-r--r-- 1 root root 0 Jan 1 1970 header drw-r--r-- 1 root root 0 Jan 1 1970 libs drw-r--r-- 1 root root 0 Jan 1 1970 sections
  • 81. estensione ad altri formati binari astrazione dal formato interfaccia verso exec()
  • 82. etcd-fs A replicated filesystem on top of etcd. Autore: Jonathan Leibiusky Source: https://github.com/xetorthio/etcd-fs
  • 83. fusepy Simple ctypes bindings for FUSE. Autore: Terence Honles Source: https://github.com/fusepy/fusepy
  • 84. GlusterFS GlusterFS is a scalable network filesystem. Using common off-the-shelf hardware, you can create large, distributed storage solutions for media streaming, data analysis, and other data- and bandwidth-intensive tasks. Source: http://www.gluster.org/
  • 85. PNGdrive PNG meets Steganography meets Fuse: the easiest way to have plausible deniability. Source: https://code.google.com/p/pngdrive/
  • 86. WikipediaFS WikipediaFS is a virtual filesystem which allows users to view and edit Wikipedia articles as if they were real files on a local disk drive. Source: https://en.wikipedia.org/wiki/WikipediaFS
  • 87. Colofóne Presentazione composta con vim e Hovercraft! su Ubuntu Saucy. Featuring Google Fonts: Libre Baskerville, Racing Sans One, Satisfy.