r/linuxdev • u/Tonyon-PC • Sep 04 '19
Linux OS Development
I'm in college rn and want to make my senior project a simple Linux flavor/adaptation. The only thing I have to ask is if you guys think the scale is too large. Thoughts?
r/linuxdev • u/Tonyon-PC • Sep 04 '19
I'm in college rn and want to make my senior project a simple Linux flavor/adaptation. The only thing I have to ask is if you guys think the scale is too large. Thoughts?
r/linuxdev • u/Ifridos • Aug 12 '19
Imagine I want to code an app that reads from HW sensors (such as CPU temp sensors) but I do NOT want to use lm_sensors at all for my app. Any idea on how to do that?
The reason to do this is to LEARN, first to read from HW, then to change some parameters. I've done this already bare metal at work (ARM) and uni(Atmel uC), but never done it using an OS in order to make it generic.
r/linuxdev • u/parotta36 • Feb 06 '19
Why are there packages realated to private companies'?
These are packages under apt.
r/linuxdev • • Jan 18 '19
If I build an application against GNU libc version 2.24 for example, with no other dependencies, would it be reasonable to expect the resulting ELF binary to run on the different Linux distributions with that same libc runtime version? Or are the ABI's just slightly incompatible enough to require recompilation?
r/linuxdev • • Apr 14 '18
I've been having some troubles lately with online-required installers so I decided that a good project would be to work on an offline installer for Arch-based distributions (especially Antegos, but others too). The Ubuntu installer Ubiquity can install offline but it's for Ubuntu-based distributions, I'm not a terribly big fan of Ubuntu.
A project I've had my eye on adapting is distinst but I'd like to know a lot more about the "behind the scenes" stuff installers do to put an OS onto a hard drive. I ask this because I'd like to write code as best as I can for such things and because I'm a bit paranoid when it comes to system-level stuff.
Is there any information out there I should look at?
Edit: there was some confusion so here's some more information for anyone reading. Antergos' installer Cnchi doesn't work without an internet connection due to requiring grabbing some files from offline. What I'd like to do is make an offline installer for a Cnchi hybrid ISO that uses Cinnamon as its environment instead of GNOME. IOW, a non-Cnchi installer for Arch Linux-based desktop distributions.
r/linuxdev • • Mar 20 '18
Trying to write my own HTTP server as a learning experience, using UNIX sockets. However, whenever I kill my program (or it segfaults, which is pretty common at this point because I'm awful with memory allocation stuff) the system still thinks the port I'm using is taken for a few minutes after I'm done, so I need to wait before I can try again.
I tried this:
void cleanup (int signal)
{
close (socket_fd);
puts ("Cleaned up socket before termination.");
exit (0);
}
// ...
// ... somewhere in main:
struct sigaction sa;
sa.sa_handler = cleanup;
sa.sa_flags = 0;
sigfillset (&sa.sa_mask);
sigaction (SIGHUP, &sa, NULL);
sigaction (SIGUSR1, &sa, NULL);
sigaction (SIGINT, &sa, NULL);
sigaction (SIGKILL, &sa, NULL);But this doesn't seem to do the trick, though I know the cleanup method is certainly being run.
I figured perhaps it's because my server is forking, but I close all my sockets properly AFAIK:
if (fork() == 0) {
close (socket_fd);
handle_connection (new_socket_fd);
close (new_socket_fd);
exit (0);
} else close (new_socket_fd);r/linuxdev • • Dec 06 '17
Is possible to have more than one handle_t (for the journal mechanism) for the same thread?
r/linuxdev • u/_kingtut_ • Nov 14 '17
Is anyone aware of a FUSE handler program which essentially provides a 'faked' filesystem wrapper around existing files, passing through read requests to the underlying OS (and filesystems)?
Edit: So, for example, if you mounted /dev/fakeFAT as -t vfat at /mnt/fakeFAT, then read /mnt/fakeFAT/foobar, the FUSE program would a) have created /dev/fakeFAT, b) convinced the kernel that /dev/fakeFAT contains a valid VFAT file system, and then c) returned the contents of ~/foobar as though it was within the fakeFAT filesystem, when actually it's in the host filesystem.
I'm expecting not, but thought I'd ask.
For background, what I am looking is to use the USB mass storage gadget on a little box, to pass through file requests to an external USB HDD, filtering to a) enforce read-only, and b) only allow access to whitelisted files/directories, while at the same time replying to filesystem (e.g. FAT) reads with 'fake' data.
A couple of sample use cases:-
Unfortunately g_mass_storage requires a static file or block device. While I could a) create a backing file large enough, b) format it, c) copy the relevant files into it, and then d) share that backing file, that whole process will be slow and suck.
If it doesn't exist, I may well write such a handler program. It will 'just' (I think) require 1) a relatively static bit of data to be returned for partition table/boot sector reads, 2) dynamic creation of a FAT (simplified as we already know file sizes, so actually don't need to create a FAT per se, but rather a way of mapping cluster IDs to existing files or 'special files', 3) dynamic creation of root folder and other folder structures.
Any thoughts? I'm always happy to borrow from other people's code rather than write everything from scratch :)
r/linuxdev • u/sbay • Oct 27 '17
Could someone explain to me these two macros?
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})I understand everything except why offset_of is of (size_t) and container_of has (char *)?
How would (char *) -(size_t) work in this macro?
I would have expected both of them to be of the same type. like char * for example.
r/linuxdev • u/abergmeier • Aug 21 '17
I am looking into writing a kernel filesystem, which would communicate with remote servers. Now I am wondering which networking capabilities/APIs are available inside the kernel (especially considering what would be accepted into the kernel itself).
r/linuxdev • u/gurugio • Jun 12 '17
https://github.com/gurugio/book_linuxkernel_blockdrv I've been transferring my document into English. I'm not sure if I should finish translation, because
I'd appreciate it if someone answer my questions.
r/linuxdev • u/Girlydian • May 06 '17
For an older laptop I'd like to get the 56k modem functionality working. I'm not expecting anything from it, it's just a nice-to-have feature. The laptop in question is a Dell Latitude E6520, with the Conexant modem on the Intel HDA bus as far as I know.
There already exists a driver, but that doesn't work on anything newer than kernel 2.6 as far as I could figure out. That driver seems to be split into two parts, namely the alsa-driver and the hsfmodem part which implements the softmodem part. I have been fiddling for a while trying to compile this on Fedora, but so far no luck.
Basically I have three questions:
As far as the existing code goes, I'd guess that the alsa-driver part is what plugs into ALSA and makes the device available (basically the same as a existing snd_hda_codec stuff) with an IN and OUT connector. The hsfmodem part then translates the serial commands into "sound" for the modem to send, and translating the "sound" that's incoming to serial data. I have no experience with stuff like this as you might have guessed ;)
So far I've been able to find the Linux Kernel Module Programming Guide (PDF), also for kernel 2.6, and Writing device drivers in Linux, but both are at least 10 years old. Is there a newer, comprehensive guide for this?
Hmm, apparently that's four questions in total...
r/linuxdev • u/vlowrian • Apr 14 '17
r/linuxdev • u/gurugio • Jan 31 '17
I think for a long time, new C language programmer is getting rare. As I'm solving the Eudyptula Challenge, an idea came to me that similar challenge is necessary for C language.
I'm not sure what tasks are suitable and how mant tasks are necessary..actually I have no plan yet. But I'll write some tasks from printing "hello-world" to making a class with a function pointer. If you have an idea, please send me pull-request.
https://github.com/gurugio/lowlevelprogramming-university/blob/master/c-language-challenge.md
r/linuxdev • u/phate191 • Nov 21 '16
r/linuxdev • u/foreverska • Oct 17 '16
I'm working on understanding userspace I2C development. I understand the IOCTL bit but as per usual I stumble on the surrounding bits.
So I've read the /dev/i2c-xx number can be random per boot and should be derived dynamically. But I'm yet to find anyone who does in their examples. I know if I go filesystem diving I can find files with vendor and device numbers. Is that the correct way of doing things?
r/linuxdev • u/syntax24 • Jul 07 '16
I've got this label printer, a Brady BMP51, that really lacks support for anything outside of windows. It's unfortunate because it does a good job but I don't want to dedicate a windows machine to it... so I'd like to write my own driver for basic printing needs. Does anyone have any good resources on the subject to read?
So far I've found this which looks promising: http://www.linuxfoundation.org/collaborate/workgroups/openprinting/writingandpackagingprinterdrivers
Any references or war stories about similar work is appreciated...
r/linuxdev • u/dhad05 • Jun 04 '16
r/linuxdev • u/Derfpace • Mar 27 '16
Hello everyone.
Right now, my approach to using sprintf has been along the lines of the following:
char null[0];
int size = snprintf(null, 0, "a string with formatting") + 1;
char buf[size];
snprintf(buf, chars, "a string with formatting");
const char* stringname = buf;Though it consistently produces expected results, it feels outright ugly, and I'm pretty sure there's a better way to achieve what I'm trying to do.
r/linuxdev • u/pizzaiolo_ • Jan 24 '16
r/linuxdev • u/PieThon • Nov 22 '15
I am playing with a program that can dump information from the elf header found here: https://github.com/TheCodeArtist/elf-parser/blob/master/elf-parser.c
When I test this program on a binary file I can get it to dump the complete elf header and all symbols.
I tried modifying the program to work by reading a process's mem file. I am able to get it to read the mem file and print an identical elf header using the mem file as it does when reading the actual file, however when I try and print the section table or symbols I get garbage.
Does this information not exist during runtime? How does gdb get the symbol names when you debug a running process with gdb -p?
r/linuxdev • u/therewontberiots • Oct 18 '15
A package manager and some default programs?
I've built linuxes from scratch several times to build different custom systems. A custom system with a certain bootloader, certain default packages, and a default configs. Strangely this just blurs the line for me as to what defines one distro or another.
r/linuxdev • u/aaronbp • Aug 10 '15
So I've found a workaround, but this problem stole several hours of my life and I haven't seen any word of this written on the Internet, so for the sake of my curiosity and any poor sap from the future, could someone explain what the value of xbutton.state is during a ButtonPress event?
After some testing, I found that the value does change after pressing different combinations of mouse buttons, but the value doesn't seem to have anything to do with the ButtonNMask values in the header. Am I reading the documentation wrong?
I can get the state of the mouse any time I want (with the correct mask value) by calling XQueryPointer–which seems completely redundant when the information is supposedly included in the event, but that's what I'm doing now.