SlideShare a Scribd company logo
GVFS: The making of a virtual filesystem




Alexander Larsson – alexl@redhat.com
Overview

●   What is GVFS?
●   Why do we need it?
●   How does it work?
●   How do I use it?
Why GVFS?

●   Gnome-vfs not good enough
●   Easy to use, modern API
●   VFS at the right level in the stack
●   Allow use of the vfs in Gtk+ (fileselector)
●   Few dependencies, less bloat
●   Project Ridley
Why is nobody using
              gnome‑vfs?

●   It has to many dependencies
●   Wrong place in the stack
●   API style from 1999 (not GObject based)
●   Hard to use (URIs, xfer, no utility functions)
●   Quality of implementation of some backends
●   Design errors
Gnome-vfs design errors:
                  posix model

●   Not abstracted enough from posix model
    –   Uses uid, gid and modes for permissions
    –   Move vs check_same_fs
    –   Supports read-write files
●   Doesn't have some required highlevel features
    –   Atomic save (with backups)
    –   Fixed list of file info (modeled on struct stat)
Gnome-vfs design errors:
               Stateless I/O model

●   Only persistent state is URIs and file handles
●   Most backends need state (a connection)
    –   Implicit state
●   Authentication
    –   Any operation can require authentication
    –   Password dialogs show up at wrong times
    –   Authentication doesn't know the context
    –   Callbacks cause reentrancy
    –   Gdk lock deadlock
Gnome-vfs design errors:
              In-process backends

●   No way to share data between applications
    –   Authentication
    –   Connections
    –   Caches
●   Unstable backend can crash the application
●   Backends have no control of their environment
●   libraries used by backend linked into
    application
Gnome-vfs design errors:
                  others

●   Enforces threads
●   Cancellation API has an unfixable race
    condition
●   No display names or filename encoding
    support
●   No icon support
How can we solve these issues

●   Make API so good that developers prefer it
●   Put it in glib
●   Use GObject and other modern tools
●   Make backends shared and out-of-process
●   Only link minimal code into applications
●   Make API more abstract
    –   Less posix, more generic
    –   Add highlevel features
●   Make I/O statefull
High level architecture


                                                       Posix Application
Gtk+ Application                                                   Fuse
     Gtk+                                                   Fuse mount
                               gvfs module
     GLib           dlopen()
                                  dbus
      libgio.so                               Session bus

    libgobject.so                            Private connections

      libglib.so                 GVFS
                                             Spawns
                                Daemon                Mount Daemons

                               GVFS
libgio

●   New library in glib, like gobject & gthread
●   Uses gobject
●   Provides a set of abstract APIs for I/O and files
    –   Interfaces
    –   Base classes
●   Provides some implementations of these APIs
●   Allows higher level components to interact
    even thought they are loosely coupled
gio – file system model

●   Abstract file system model
    –   GFile – reference to a file
    –   GFileInfo – information about a file or filesystem
    –   GFileEnumerator – list files in directories
    –   Streams – read and write data

          Posix                       gio
          char *path                  GFile *file
          struct stat *buf            GFileInfo *info
          struct statvfs *buf         GFileInfo *info
          int fd                      GInputStream *in,
                                      GOutputStream *out
          DIR *                       GFileEnumerator *enum
gio – GFile

●   GFile – a reference to a file
    –   Construction:
         ●   GFile *g_file_get_for_path (const char *path)
         ●   GFile *g_file_get_for_uri (const char *uri)
         ●   GFile *g_file_parse_name (const char *parse_name)
         ●   GFile *g_file_get_for_commandline_arg (const char *arg)
         ●   Cheap, doesn't do I/O
         ●   Doesn't have to exist on disk
    –   Can traverse the filesystem:
         ●   GFile *g_file_get_parent (GFile *file)
         ●   GFile *g_file_get_child (GFile *file, const char *name)
         ●   GFile *g_file_resolve_relative (GFile *file,
                                             const char *relative_path);
         ●   Never do path or URI string munging again!
gio – GFile operations

●   g_file_enumerate_children -> GFileEnumerator
●   g_file_get_info -> GFileInfo
●   g_file_get_filesystem_info -> GFileInfo
●   g_file_set_display_name
●   g_file_set_attribute
●   Other operations:
    –   copy, move, delete, trash
    –   make_directory, make_symbolic_link
    –   mount, eject
gio – file data


●   Reading files
      GFileInputStream * g_file_read     (GFile        *file,
                                          GCancellable *cancellable,
                                          GError      **error);

●   Writing files
      GFileOutputStream *g_file_append_to (GFile        *file,
                                           GCancellable *cancellable,
                                           GError      **error);
      GFileOutputStream *g_file_create    (GFile        *file,
                                           GCancellable *cancellable,
                                           GError      **error);
      GFileOutputStream *g_file_replace   (GFile        *file,
                                           time_t        mtime,
                                           gboolean      make_backup,
                                           GCancellable *cancellable,
                                           GError      **error);
gio – streams

●   Generic abstraction for I/O on streams of bytes
●   GInputStream: read(), skip(), close()
●   GOutputStream: write(), flush(), close()
●   Optionally implements GSeekable interface
●   Sharing stream APIs low in the stack allows
    loose coupling of components, eg:
    –   GdkPixbuf reads from a GInputStream
    –   Some library can read pixmap data from the net as
        a GInputStream
    –   now GdkPixbuf can read the data from the net
gio – types of streams

●   GInputStream – basic input stream
     –   GFileInputStream – adds seek and get_file_info
     –   GFilterInputStream – base class for wrapper streams
          ●   GBufferedInputStream
     –   GMemoryInputStream
     –   GSocketInputStream
●   GOutputStream – basic output stream
     –   GFileOutputStream – adds seek, truncate and get_file_info
     –   GFilterOutputStream – base class for wrapper streams
          ●   GBufferedOutputStream
     –   GMemoryOutputStream
     –   GSocketOutputStream
●   GSeekable – Interface that streams can support
gio – file information

●   GFileInfo
    –   set of key-value pairs
    –   keys are namespaced strings “ns:key”
         ●   “std:name”, “std:size”, “unix:uid”, “access:read”
    –   values are typed data
         ●   string, byte string, [u]int32, [u]int64, bool, object
●   Getting a subset of attributes
    –   GFileAttributeMatcher
    –   list of attributes, with wildcards
    –   “*”, “std:*”, “std:name,std:display_name”
gio – common GFileInfo
                namespaces

●   std – type, names, size, content type, etc
●   unix – unix specific info (inode, uid, etc)
●   access – access rights
●   mountable – can the location be mounted, etc
●   time – access time, etc (not mtime)
●   owner – string version of owner/group
●   selinux – selinux info
●   xattr – extended attributes
●   extendable...
gio – file monitoring

●   GFileMonitor (g_file_monitor_file)
●   GDirectoryMonitor (g_file_monitor_directory)
●   “changed” signal
    void (* changed) (GFileMonitor* monitor,
                      GFile* file,
                      GFile* other_file,
                      GFileMonitorEvent event_type)
●   types: changed, deleted, created, moved,
           attribute_changed, unmounted
●   Backends: fam/gamin, inotify
gio – Asynchronous I/O

●   Most operations availble in async version
●   Default implementation using thread pool
●   Uses default glib mainloop
●   Threadsafe (but callbacks are in main thread)
●   All callbacks use the same callback prototype
gio – Asynchronous API

●   Async operations are split into two calls
    –   _async() - starts the operation, then calls callback
        when ready
    –   _finish() - gets the result from the call
                    (typically called in callback)
typedef void (*GAsyncReadyCallback) (GObject *source_object,
                                     GAsyncResult *res,
                                     gpointer user_data);
void       g_file_op_async (GFile *file,
                             input_arguments args,
                             GAsyncReadyCallback callback,
                             gpointer user_data);
ReturnType g_file_op_finish (GFile *file,
                             GAsyncResult *res,
                             output_args *args,
                             GError **error);
gio – File types

●   content type
    –   ASCII string defining the type of a file
    –   platform dependent
         ●   mimetype on unix (shared mime spec)
         ●   extension on win32
         ●   OSX: Uniform Type Identifiers?
    –   equals, is_a, is_unknown, get_descriptions,
        get_icon, get_mimetype, can_be_executable
●   content guessing
    –   sniffing (on unix)
    –   filename matching
File handlers

●   GAppInfo – Represents an installed application
    –   Launch with filenames or URIs
    –   Information: Name, Description, Icon
    –   Implemented as desktop file on Unix
●   Several ways to get
    –   all installed
    –   all for content type
    –   default for content type
●   Might move to Gtk+
Icons

●   Need to support icons
    –   content types
    –   applications
    –   files
●   Problematic
    –   Can't use GdkPixbuf or GtkIconTheme
    –   Several types of icons in use
         ●   themed icons
         ●   filenames
         ●   custom backend icons (e.g. http favicons)
Icons – Solution

●   GIcon interface
    –   abstract
    –   cachable (equals() and hash())
●   GLoadableIcon interface
    –   Load icon data as a stream
●   Several Implementations
    –   GThemedIcon
    –   GFileIcon
●   Icon renderer at Gtk+ level
gvfs – How it works

●   gvfs module adds support for non-file: uris
●   I/O on such files is implemented by talking to
    daemons handling each mount
    –   general operations and metadata I/O use DBus
    –   file content I/O use custom binary protocol
●   main gvfs daemon
    –   Found and autostarted via session bus
    –   Starts and manages the mount daemons
    –   desktop style config files for each mountable
gvfs – Fuse

●   Allows backward compatibility
    –   Open and save files with non-gvfs applications
    –   Possible for file selector and file manager to
        reverse map to gvfs location
●   One mountpoint (e.g. ~/.gvfs)
●   Current mounts listed under toplevel dir
Some code

●   g_file_load_contents
●   g_file_replace_contents
Status

●   Code in git
    –   http://www.gnome.org/~alexl/git/gvfs.git
●   API usable, but not fully done or frozen
●   fuse mounts work
●   smb backend availible
●   ftp backend under development
●   Important work before freezing
    –   Nautilus port
    –   File selector support
QA




     Any questions?

More Related Content

PDF
Nge-GIT (Belajar Git Bareng)
PDF
Fisl13 gstreamer
PPTX
UDPSRC GStreamer Plugin Session VIII
PDF
Puppet at GitHub - PuppetConf 2013
PPTX
Gstreamer plugin development
PDF
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...
PDF
Page compression. PGCON_2016
PPTX
Git Basic
Nge-GIT (Belajar Git Bareng)
Fisl13 gstreamer
UDPSRC GStreamer Plugin Session VIII
Puppet at GitHub - PuppetConf 2013
Gstreamer plugin development
Development of hardware-based Elements for GStreamer 1.0: A case study (GStre...
Page compression. PGCON_2016
Git Basic

What's hot (12)

PDF
GIT_In_90_Minutes
PPTX
Advanced Git Presentation By Swawibe
PDF
GIT: Content-addressable filesystem and Version Control System
PDF
Leveraging Android's Linux Heritage at AnDevCon V
PDF
Introduction to Redis
PDF
PHP Development Tools
PDF
Git walkthrough
PDF
Take care of hundred containers and not go crazy
PDF
Programming in Linux Environment
PDF
Golang execution modes
PDF
Linux fundamental - Chap 09 pkg
PDF
نگاهی به Gtk3
GIT_In_90_Minutes
Advanced Git Presentation By Swawibe
GIT: Content-addressable filesystem and Version Control System
Leveraging Android's Linux Heritage at AnDevCon V
Introduction to Redis
PHP Development Tools
Git walkthrough
Take care of hundred containers and not go crazy
Programming in Linux Environment
Golang execution modes
Linux fundamental - Chap 09 pkg
نگاهی به Gtk3
Ad

Similar to Guadec2007 Gvfs (20)

PDF
Meiga Guadec 2009 English
PDF
Play with FILE Structure - Yet Another Binary Exploit Technique
PPTX
basics of file handling
PPTX
Basics of file handling
PPT
From gcc to the autotools
PDF
xv6 is a re−implementation of Dennis Ritchie’s and Ken Thompson’s Unix Versio...
PDF
GNU Compiler Collection - August 2005
PDF
Of Owls and IO Objects
PDF
Operating system structures
PDF
Parsing and Type checking all 2^10000 configurations of the Linux kernel
PDF
The Linux Kernel Implementation of Pipes and FIFOs
PDF
sysprog4
PDF
Android Variants, Hacks, Tricks and Resources
PDF
Linux Internals Part - 3
PDF
DOCX
Linux 系統程式--第一章 i/o 函式
PPTX
C++ - UNIT_-_V.pptx which contains details about File Concepts
PDF
POCO C++ Libraries Intro and Overview
PDF
Linux programming
Meiga Guadec 2009 English
Play with FILE Structure - Yet Another Binary Exploit Technique
basics of file handling
Basics of file handling
From gcc to the autotools
xv6 is a re−implementation of Dennis Ritchie’s and Ken Thompson’s Unix Versio...
GNU Compiler Collection - August 2005
Of Owls and IO Objects
Operating system structures
Parsing and Type checking all 2^10000 configurations of the Linux kernel
The Linux Kernel Implementation of Pipes and FIFOs
sysprog4
Android Variants, Hacks, Tricks and Resources
Linux Internals Part - 3
Linux 系統程式--第一章 i/o 函式
C++ - UNIT_-_V.pptx which contains details about File Concepts
POCO C++ Libraries Intro and Overview
Linux programming
Ad

Recently uploaded (20)

PDF
Hybrid model detection and classification of lung cancer
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
project resource management chapter-09.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Approach and Philosophy of On baking technology
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Hybrid model detection and classification of lung cancer
A comparative study of natural language inference in Swahili using monolingua...
project resource management chapter-09.pdf
cloud_computing_Infrastucture_as_cloud_p
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
Getting Started with Data Integration: FME Form 101
Programs and apps: productivity, graphics, security and other tools
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Approach and Philosophy of On baking technology
Zenith AI: Advanced Artificial Intelligence
NewMind AI Weekly Chronicles - August'25-Week II
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Assigned Numbers - 2025 - Bluetooth® Document
gpt5_lecture_notes_comprehensive_20250812015547.pdf
OMC Textile Division Presentation 2021.pptx
1. Introduction to Computer Programming.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
1 - Historical Antecedents, Social Consideration.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf

Guadec2007 Gvfs

  • 1. GVFS: The making of a virtual filesystem Alexander Larsson – alexl@redhat.com
  • 2. Overview ● What is GVFS? ● Why do we need it? ● How does it work? ● How do I use it?
  • 3. Why GVFS? ● Gnome-vfs not good enough ● Easy to use, modern API ● VFS at the right level in the stack ● Allow use of the vfs in Gtk+ (fileselector) ● Few dependencies, less bloat ● Project Ridley
  • 4. Why is nobody using gnome‑vfs? ● It has to many dependencies ● Wrong place in the stack ● API style from 1999 (not GObject based) ● Hard to use (URIs, xfer, no utility functions) ● Quality of implementation of some backends ● Design errors
  • 5. Gnome-vfs design errors: posix model ● Not abstracted enough from posix model – Uses uid, gid and modes for permissions – Move vs check_same_fs – Supports read-write files ● Doesn't have some required highlevel features – Atomic save (with backups) – Fixed list of file info (modeled on struct stat)
  • 6. Gnome-vfs design errors: Stateless I/O model ● Only persistent state is URIs and file handles ● Most backends need state (a connection) – Implicit state ● Authentication – Any operation can require authentication – Password dialogs show up at wrong times – Authentication doesn't know the context – Callbacks cause reentrancy – Gdk lock deadlock
  • 7. Gnome-vfs design errors: In-process backends ● No way to share data between applications – Authentication – Connections – Caches ● Unstable backend can crash the application ● Backends have no control of their environment ● libraries used by backend linked into application
  • 8. Gnome-vfs design errors: others ● Enforces threads ● Cancellation API has an unfixable race condition ● No display names or filename encoding support ● No icon support
  • 9. How can we solve these issues ● Make API so good that developers prefer it ● Put it in glib ● Use GObject and other modern tools ● Make backends shared and out-of-process ● Only link minimal code into applications ● Make API more abstract – Less posix, more generic – Add highlevel features ● Make I/O statefull
  • 10. High level architecture Posix Application Gtk+ Application Fuse Gtk+ Fuse mount gvfs module GLib dlopen() dbus libgio.so Session bus libgobject.so Private connections libglib.so GVFS Spawns Daemon Mount Daemons GVFS
  • 11. libgio ● New library in glib, like gobject & gthread ● Uses gobject ● Provides a set of abstract APIs for I/O and files – Interfaces – Base classes ● Provides some implementations of these APIs ● Allows higher level components to interact even thought they are loosely coupled
  • 12. gio – file system model ● Abstract file system model – GFile – reference to a file – GFileInfo – information about a file or filesystem – GFileEnumerator – list files in directories – Streams – read and write data Posix gio char *path GFile *file struct stat *buf GFileInfo *info struct statvfs *buf GFileInfo *info int fd GInputStream *in, GOutputStream *out DIR * GFileEnumerator *enum
  • 13. gio – GFile ● GFile – a reference to a file – Construction: ● GFile *g_file_get_for_path (const char *path) ● GFile *g_file_get_for_uri (const char *uri) ● GFile *g_file_parse_name (const char *parse_name) ● GFile *g_file_get_for_commandline_arg (const char *arg) ● Cheap, doesn't do I/O ● Doesn't have to exist on disk – Can traverse the filesystem: ● GFile *g_file_get_parent (GFile *file) ● GFile *g_file_get_child (GFile *file, const char *name) ● GFile *g_file_resolve_relative (GFile *file, const char *relative_path); ● Never do path or URI string munging again!
  • 14. gio – GFile operations ● g_file_enumerate_children -> GFileEnumerator ● g_file_get_info -> GFileInfo ● g_file_get_filesystem_info -> GFileInfo ● g_file_set_display_name ● g_file_set_attribute ● Other operations: – copy, move, delete, trash – make_directory, make_symbolic_link – mount, eject
  • 15. gio – file data ● Reading files GFileInputStream * g_file_read (GFile *file, GCancellable *cancellable, GError **error); ● Writing files GFileOutputStream *g_file_append_to (GFile *file, GCancellable *cancellable, GError **error); GFileOutputStream *g_file_create (GFile *file, GCancellable *cancellable, GError **error); GFileOutputStream *g_file_replace (GFile *file, time_t mtime, gboolean make_backup, GCancellable *cancellable, GError **error);
  • 16. gio – streams ● Generic abstraction for I/O on streams of bytes ● GInputStream: read(), skip(), close() ● GOutputStream: write(), flush(), close() ● Optionally implements GSeekable interface ● Sharing stream APIs low in the stack allows loose coupling of components, eg: – GdkPixbuf reads from a GInputStream – Some library can read pixmap data from the net as a GInputStream – now GdkPixbuf can read the data from the net
  • 17. gio – types of streams ● GInputStream – basic input stream – GFileInputStream – adds seek and get_file_info – GFilterInputStream – base class for wrapper streams ● GBufferedInputStream – GMemoryInputStream – GSocketInputStream ● GOutputStream – basic output stream – GFileOutputStream – adds seek, truncate and get_file_info – GFilterOutputStream – base class for wrapper streams ● GBufferedOutputStream – GMemoryOutputStream – GSocketOutputStream ● GSeekable – Interface that streams can support
  • 18. gio – file information ● GFileInfo – set of key-value pairs – keys are namespaced strings “ns:key” ● “std:name”, “std:size”, “unix:uid”, “access:read” – values are typed data ● string, byte string, [u]int32, [u]int64, bool, object ● Getting a subset of attributes – GFileAttributeMatcher – list of attributes, with wildcards – “*”, “std:*”, “std:name,std:display_name”
  • 19. gio – common GFileInfo namespaces ● std – type, names, size, content type, etc ● unix – unix specific info (inode, uid, etc) ● access – access rights ● mountable – can the location be mounted, etc ● time – access time, etc (not mtime) ● owner – string version of owner/group ● selinux – selinux info ● xattr – extended attributes ● extendable...
  • 20. gio – file monitoring ● GFileMonitor (g_file_monitor_file) ● GDirectoryMonitor (g_file_monitor_directory) ● “changed” signal void (* changed) (GFileMonitor* monitor, GFile* file, GFile* other_file, GFileMonitorEvent event_type) ● types: changed, deleted, created, moved, attribute_changed, unmounted ● Backends: fam/gamin, inotify
  • 21. gio – Asynchronous I/O ● Most operations availble in async version ● Default implementation using thread pool ● Uses default glib mainloop ● Threadsafe (but callbacks are in main thread) ● All callbacks use the same callback prototype
  • 22. gio – Asynchronous API ● Async operations are split into two calls – _async() - starts the operation, then calls callback when ready – _finish() - gets the result from the call (typically called in callback) typedef void (*GAsyncReadyCallback) (GObject *source_object, GAsyncResult *res, gpointer user_data); void g_file_op_async (GFile *file, input_arguments args, GAsyncReadyCallback callback, gpointer user_data); ReturnType g_file_op_finish (GFile *file, GAsyncResult *res, output_args *args, GError **error);
  • 23. gio – File types ● content type – ASCII string defining the type of a file – platform dependent ● mimetype on unix (shared mime spec) ● extension on win32 ● OSX: Uniform Type Identifiers? – equals, is_a, is_unknown, get_descriptions, get_icon, get_mimetype, can_be_executable ● content guessing – sniffing (on unix) – filename matching
  • 24. File handlers ● GAppInfo – Represents an installed application – Launch with filenames or URIs – Information: Name, Description, Icon – Implemented as desktop file on Unix ● Several ways to get – all installed – all for content type – default for content type ● Might move to Gtk+
  • 25. Icons ● Need to support icons – content types – applications – files ● Problematic – Can't use GdkPixbuf or GtkIconTheme – Several types of icons in use ● themed icons ● filenames ● custom backend icons (e.g. http favicons)
  • 26. Icons – Solution ● GIcon interface – abstract – cachable (equals() and hash()) ● GLoadableIcon interface – Load icon data as a stream ● Several Implementations – GThemedIcon – GFileIcon ● Icon renderer at Gtk+ level
  • 27. gvfs – How it works ● gvfs module adds support for non-file: uris ● I/O on such files is implemented by talking to daemons handling each mount – general operations and metadata I/O use DBus – file content I/O use custom binary protocol ● main gvfs daemon – Found and autostarted via session bus – Starts and manages the mount daemons – desktop style config files for each mountable
  • 28. gvfs – Fuse ● Allows backward compatibility – Open and save files with non-gvfs applications – Possible for file selector and file manager to reverse map to gvfs location ● One mountpoint (e.g. ~/.gvfs) ● Current mounts listed under toplevel dir
  • 29. Some code ● g_file_load_contents ● g_file_replace_contents
  • 30. Status ● Code in git – http://www.gnome.org/~alexl/git/gvfs.git ● API usable, but not fully done or frozen ● fuse mounts work ● smb backend availible ● ftp backend under development ● Important work before freezing – Nautilus port – File selector support
  • 31. QA Any questions?