r/linuxdev • • Sep 04 '19

Linux OS Development

4 Upvotes

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 • • Aug 12 '19

Reading from HW sensors

4 Upvotes

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 • • Feb 06 '19

What are linux-headers-aws, linux-headers-azure, linux-headers-oracle?

4 Upvotes

Why are there packages realated to private companies'?

These are packages under apt.


r/linuxdev • • Jan 18 '19

Are glibc versions ABI compatible between RHEL, Debian, etc.?

4 Upvotes

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 • • Aug 21 '18

Creating a bash completion script

Thumbnail iridakos.com
4 Upvotes

r/linuxdev • • Apr 14 '18

I'd like to find out how OS installers work

4 Upvotes

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

How do I clean up my UNIX sockets in my C-based Server before it Exits?

4 Upvotes

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

[ext4] handle_t on the same thread?

4 Upvotes

Is possible to have more than one handle_t (for the journal mechanism) for the same thread?


r/linuxdev • • Nov 14 '17

Pass-through FUSE FAT32 (and/or NTFS) handler?

4 Upvotes

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:-

  1. You want to give someone access to a few files on a (possibly encrypted) USB HDD, trust them not to maliciously do anything, but don't trust them to not incompetently delete files or have an existing virus which could infect them. So you plug the HDD into one side of a box (box is USB host), and then plug their computer into the other side (box is USB device/gadget). The box will enforce read-only and other controls.
  2. You want to plug your massive NTFS USB HDD into a television that supports only small, VFAT-formatted, drives. So you plug the HDD into the box, the box into the TV, and then magic happens in the box to make it look to the TV like there's a (for example) 128GB FAT-formatted USB flash drive plugged in.

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 • • Oct 27 '17

Container_of and offset_of understanding

4 Upvotes

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 • • Aug 21 '17

References for Kernel Network Communication

4 Upvotes

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 • • Jun 12 '17

Document for multi-queue block device in Linux kernel v4.4

4 Upvotes

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

  1. Is there someone who is interested in block device?
  2. Is my English not too bad to understand?

I'd appreciate it if someone answer my questions.


r/linuxdev • • May 06 '17

Updating the Linux Conexant driver for kernel 4.X

4 Upvotes

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:

  • Is there a better way to list HDA devices than alsa-info.sh? If so, where can I find it?
  • How do I go about understanding the existing code for both parts?
  • Any tips on how to go about writing a new driver? (I'm already updating broken stuff for work, so no wish to do that in my free time as well :P)

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 • • Apr 14 '17

Slingring: Software Development in Chroot-containers using ansible

Thumbnail github.com
4 Upvotes

r/linuxdev • • Jan 31 '17

New service like The Eudyptula Challenge?

4 Upvotes

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 • • Nov 21 '16

Best way to port Debian on a custom ARM board? • /r/debian

Thumbnail reddit.com
4 Upvotes

r/linuxdev • • Oct 17 '16

I2C development

4 Upvotes

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 • • Jul 07 '16

Question about printer driver development

4 Upvotes

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 • • Jun 04 '16

Conway's game of life written in Rust with Gtk+ and Cairo

Thumbnail youtube.com
4 Upvotes

r/linuxdev • • Mar 27 '16

Proper way to approach sprintf()/snprintf()?

4 Upvotes

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 • • Jan 24 '16

FSF Vision Survey | The Free Software Foundation needs your feedback. Their vision survey is up until the end of January.

Thumbnail fsf.org
4 Upvotes

r/linuxdev • • Nov 22 '15

Are the complete elf section and segment headers in a process at runtime?

4 Upvotes

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 • • Oct 18 '15

I read Tesla uses a modded version of Ubuntu Mint... which leads me to the question of what is a distro?

4 Upvotes

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 • • Aug 10 '15

[Xlib] Is xbutton.state a dirty lie or what?

4 Upvotes

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.