SlideShare a Scribd company logo
1 of 31
Download to read offline
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

What's hot

Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeMd Swawibe Ul Alam
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemTommaso Visconti
 
Leveraging Android's Linux Heritage at AnDevCon V
Leveraging Android's Linux Heritage at AnDevCon VLeveraging Android's Linux Heritage at AnDevCon V
Leveraging Android's Linux Heritage at AnDevCon VOpersys inc.
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisRizky Abdilah
 
Take care of hundred containers and not go crazy
Take care of hundred containers and not go crazyTake care of hundred containers and not go crazy
Take care of hundred containers and not go crazyHonza Horák
 
Programming in Linux Environment
Programming in Linux EnvironmentProgramming in Linux Environment
Programming in Linux EnvironmentDongho Kang
 
Golang execution modes
Golang execution modesGolang execution modes
Golang execution modesTing-Li Chou
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgKenny (netman)
 
نگاهی به Gtk3
نگاهی به Gtk3نگاهی به Gtk3
نگاهی به Gtk3Ali Vakilzade
 

What's hot (12)

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

Similar to Guadec2007 Gvfs

Git - Some tips to do it better
Git - Some tips to do it betterGit - Some tips to do it better
Git - Some tips to do it betterJonas De Smet
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucketazwildcat
 
Javascript, the GNOME way (JSConf EU 2011)
Javascript, the GNOME way (JSConf EU 2011)Javascript, the GNOME way (JSConf EU 2011)
Javascript, the GNOME way (JSConf EU 2011)Igalia
 
Javascript in linux desktop (ICOS ver.)
Javascript in linux desktop (ICOS ver.)Javascript in linux desktop (ICOS ver.)
Javascript in linux desktop (ICOS ver.)Yuren Ju
 
Improving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetImproving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetNicolas Brousse
 
Grails 101
Grails 101Grails 101
Grails 101Lim Kin
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and PracticeBo-Yi Wu
 
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...Nicolas Brousse
 
Cloud Optimized GeotTIFFs: enabling efficient cloud workflows
Cloud Optimized GeotTIFFs: enabling efficient cloud workflows Cloud Optimized GeotTIFFs: enabling efficient cloud workflows
Cloud Optimized GeotTIFFs: enabling efficient cloud workflows Eugene Cheipesh
 
Git, Beginner to Advanced Survey
Git, Beginner to Advanced SurveyGit, Beginner to Advanced Survey
Git, Beginner to Advanced SurveyRafal Rusin
 
How To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneHow To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneVEXXHOST Private Cloud
 

Similar to Guadec2007 Gvfs (20)

Advanted git
Advanted git Advanted git
Advanted git
 
Git - Some tips to do it better
Git - Some tips to do it betterGit - Some tips to do it better
Git - Some tips to do it better
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
 
Javascript, the GNOME way (JSConf EU 2011)
Javascript, the GNOME way (JSConf EU 2011)Javascript, the GNOME way (JSConf EU 2011)
Javascript, the GNOME way (JSConf EU 2011)
 
Javascript in linux desktop (ICOS ver.)
Javascript in linux desktop (ICOS ver.)Javascript in linux desktop (ICOS ver.)
Javascript in linux desktop (ICOS ver.)
 
Improving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetImproving Operations Efficiency with Puppet
Improving Operations Efficiency with Puppet
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Grails 101
Grails 101Grails 101
Grails 101
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
Grooscript gr8conf 2015
Grooscript gr8conf 2015Grooscript gr8conf 2015
Grooscript gr8conf 2015
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and Practice
 
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
Puppet Camp Silicon Valley 2015: How TubeMogul reached 10,000 Puppet Deployme...
 
Cloud Optimized GeotTIFFs: enabling efficient cloud workflows
Cloud Optimized GeotTIFFs: enabling efficient cloud workflows Cloud Optimized GeotTIFFs: enabling efficient cloud workflows
Cloud Optimized GeotTIFFs: enabling efficient cloud workflows
 
GIT from n00b
GIT from n00bGIT from n00b
GIT from n00b
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git, Beginner to Advanced Survey
Git, Beginner to Advanced SurveyGit, Beginner to Advanced Survey
Git, Beginner to Advanced Survey
 
Grilo
GriloGrilo
Grilo
 
How To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneHow To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub Clone
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

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?