Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6082049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:14:43+00:00 2026-05-23T11:14:43+00:00

I have written python code to a mount fuse on a point mount. It

  • 0

I have written python code to a mount fuse on a point mount. It always gives invalid argument error. I have tried the same program in C and it works fine. Can any of python Guru’s help me out in finding what the problem is, I have pasted the code here.

#!/usr/bin/python

import stat
import os
import ctypes
from ctypes.util import find_library

libc = ctypes.CDLL (find_library ("c"))

def fuse_mount_sys (mountpoint, fsname):
        fd = file.fileno (file ("/dev/fuse", 'w+'))
        if fd < 0:
                raise OSError("Could not open /dev/fuse")

        mnt_param = "%s,fd=%i,rootmode=%o,user_id=%i,group_id=%i" \
                        % ("allow_other,default_permissions,max_read=131072", \
                        fd, stat.S_IFDIR, os.getuid(), os.getgid())

        ret = libc.mount ("fuse", "/mount", "fuse", 0, mnt_param)
        if ret < 0:
                raise OSError("mount failed with code " + str(ret))
        return fd

fds = fuse_mount_sys ("/mount", "fuse")

mount syntax is:

int mount(const char *source, const char *target,
                 const char *filesystemtype, unsigned long mountflags,
                 const void *data);

I tried using swig and also writing the program using in C and then creating a .so from it and they worked. But I am interested in writing in pure python. Thanks in advance.

output of strace:

$ strace -s 100 -v -e mount python fuse-mount.py 
mount("fuse", "/mount", "fuse", 0, "allow_other,default_permissions,max_read=131072,fd=3,rootmode=40000,user_id=0,group_id=0") = -1 EINVAL (Invalid argument)


$ strace -s 100 -v -e mount ./a.out 
mount("fuse", "/mount", "fuse", 0, "allow_other,default_permissions,max_read=131072,fd=3,rootmode=40000,user_id=0,group_id=0") = 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:14:44+00:00Added an answer on May 23, 2026 at 11:14 am

    ctypes.c_void_p cannot be initialized with a string. Instead, just use a string without c_void_p.

    You can then compare the output of

    strace -v -e mount python mymount.py
    

    and

    strace -v -e mount ./mymount-c
    

    until they match.

    Also, make sure the file handle fd is still open when you call mount. file("/dev/fuse", 'w+') will be automatically garbage-collected and closed by some Python implementations, including cpython. You can prevent this by assigning the result of file("/dev/fuse") to a variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written code for threading in Python. It throws the error below. How
I have written a Python program to find the carrier of a cell phone
I have written the same program (open text file and display contents) in C
I am new to both python, and to threads. I have written python code
I am an intermediate level Python Programmer and I have written a Python program
I have written the following Python code: #!/usr/bin/python # -*- coding: utf-8 -*- import
I have written a good bit of code in python and it works great.
Possible Duplicate: How to initialize a two-dimensional array in Python? I have always written
I have a program written in python that uses dbus to detect inserted usb
I have written a python console based program. It takes few arguments (like file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.