Skip to content

Instantly share code, notes, and snippets.

@aerostitch
Created September 2, 2016 15:58
Show Gist options
  • Save aerostitch/97ce91f1a1f4af59649e2c808fc62db4 to your computer and use it in GitHub Desktop.
Save aerostitch/97ce91f1a1f4af59649e2c808fc62db4 to your computer and use it in GitHub Desktop.
import ctypes
import os
def mount(source, target, fs, options=''):
ret = ctypes.CDLL('libc.so.6', use_errno=True).mount(source, target, fs, 0, options)
if ret < 0:
errno = ctypes.get_errno()
raise RuntimeError("Error mounting {} ({}) on {} with options '{}': {}".
format(source, fs, target, options, os.strerror(errno)))
mount('/dev/sdb1', '/mnt', 'ext4', 'rw')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment