USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

Writing a daemon. need help with FUSE.

 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Shell Scripting and Programming
View previous topic :: View next topic  
Author Message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Oct 29, 2024 2:59 pm    Post subject: Writing a daemon. need help with FUSE. Reply with quote

I am working on a program that manipulates raw block devices and it requires knowledge of the exact partition size.

I've tried a couple of different approaches (fopen/fseek, and statvfs)

both give incorrect results (at least when I tried) and statvfs has the limitation that one or more of the block devices i will be manipulating is not formatted so it would fail.

because of the libraries i am using i am limited to standard GNU C99 so I'm hoping someone knows how i can pull this off, or has better google-fu than I and can find out how.

Thanks in advance!

-Patrick



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)


Last edited by Lord.DragonFly.of.Dawn on Sun Nov 02, 2024 4:08 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Rootboy
Sr. Member


Joined: 11 Aug 2024
Posts: 1947
Location: Lewisburg, Tennessee

PostPosted: Sat Nov 01, 2024 3:51 am    Post subject: Reply with quote

dd to /dev/null maybe?

Check out:

http://www.uwsg.iu.edu/hypermail/linux/kernel/9706.1/0228.html



_________________
OpenSuSE 10.3
Back to top
View user's profile Send private message
nukes
Linux Guru


Joined: 29 Aug 2024
Posts: 4558

PostPosted: Sat Nov 01, 2024 3:04 pm    Post subject: Reply with quote

http://dsrg.mff.cuni.cz/~ceres/sch/osy/slides/ch04s02s02s01s01s01.html should give you the structures you need. The partition table is the first 512 bytes of the disk, just open it and read it (as in the system calls open and read, not the fread/fopen - read the man pages)

Quote:
because of the libraries i am using i am limited to standard GNU C99 so I'm hoping someone knows how i can pull this off, or has better google-fu than I and can find out how.

I think you're confused there, C99 is a standard, gnu99 is c99 + gnu extensions - the bits they haven't implemented.
As to google-fu, the first two results for "ibm partition table" were http://en.wikipedia.org/wiki/Master_boot_record and the link above, both of which have the information you need Wink



_________________
Gentoo x86-64 2.6.29.1
FreeBSD 7-CURRENT
Arch x86 2.6.30
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Sat Nov 01, 2024 8:27 pm    Post subject: Reply with quote

Actually. I had already solved the problem. (about ten minutes ago actually)

After doing some research I determined that the device i was working with was only a 2GiB hard drive rather than the 20GiB i had been told it was. That does explain the factor of ten error i was getting.

so an open + lseek is working and will work for devices up to (with a 64 bit off_t type) 2^64 bytes or 16EiB! Plenty big enough for me!

Still wish i had been told the accurate drive sizes ahead of time. Wouldn't have wasted as much time trying to debug a algorithm that was already working.



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Sun Nov 02, 2024 4:08 am    Post subject: Reply with quote

okay. new problem, same program so i'll reuse the thread.

The program is a file system daemon using the fuse libraries.

<strike>It's working for almost everything i want it to, but for some reason the file system exported by fuse is completely unreadable by anyone other than the user that created it (this includes the superuser) Since i intend to export a file (statistics) that should at least be readable by everyone on the system this is a bit of a problem.

Does anyone know a trick that can solve this? I could simply write it to a file sitting outside of the fuse file system, but that is a rather inelegant solution to me.</strike>

.... never mind..... I'm just an idiot is all.



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Shell Scripting and Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2024-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2024-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse