sendfile() / TransmitFile() with encryption/decryption - linux

How do I get the benefit of sendfile() (on Linux) and TransmitFile() (on Windows) if I also want to use encryption? Are there any Linux kernel modules or Windows drivers that provide this functionality? The only thing I've found this far is an implementation on FreeBSD by Netflix, but unfortunately that is not my two target platforms.

Google for "Linux KTLS". It's pretty new/experimental though.

Related

Considering Linux is not supporting _OSI("Linux") ACPI object, any reliance way to use it in BIOS

Considering Linux is not supporting _OSI("Linux") ACPI object, any reliance way to use it in BIOS such that this ACPI _OSI works across all variants of Linux. acpi_osi has to be set to kernel params else it does not take effect if used in BIOS to to decide on some IO port programming or any other OS specific checks asl.
refering below link:
https://www.kernel.org/doc/html/latest/firmware-guide/acpi/osi.html
As that link outlines, Linux doesn't support _OSI("Linux") because many BIOS manufacturers implemented it incompetently and failed to test their environments properly. As such, you should aim to write your BIOS code in a way that works for any OS. This will mean that your BIOS will work not only on Windows and Linux, but on other OSes, like FreeBSD, NetBSD, and OpenBSD.
If it turns out that your system has a bug, try to make sure your BIOS handles it in the firmware if possible instead of offloading it to your Windows driver. If that's not possible, you can use the mechanism outlined in that link to use an OEM-specific hook, provided you send a patch to the kernel.
Linux will intentionally avoid attempts to be detected in the firmware, so you are better off not trying to do it at all. Note that because Linux tends to change rather rapidly, trying to make an assumption about how all versions of it work is probably not going to work out well.

How can I use Node.js with the filesystem to map a fake drive?

When mapping a network drive in windows or mounting an SSH drive in Linux, it appears to the OS as a regular drive even though it's a completely different protocol and filesystem behind the scenes.
There are programs that can do that for you like CloudMounter and MountainDuck so I'm wondering:
Is there a cross-platform way I can use Node.js to do something similar?
Node.js doesn't have a built-in way to do this but the popular FUSE library (https://github.com/libfuse/libfuse) has bindings on NPM:
https://www.npmjs.com/package/fuse-bindings
https://www.npmjs.com/package/fused
(I wrote the second one)

How to compile the Linux kernel to be as small as possible?

I'm working on a side project which requires me to configure and compile a tiny Linux System based on Ubuntu.
The result should be a tiny OS with the following features:
A Bootloader
A Kernel
A Process
A Thread
Miscellaneous (if possible)
A File System
Virtual memory
A Console
I read lots of documents about it, one of them being: http://users.cecs.anu.edu.au/~okeefe/p2b/buildMin/buildMin.html#toc3
I deleted the file system, and recompiled the kernel using make xconfig. I tried to deactivate modules and configurations many times, but it's not working for me.
How can I configure the kernel for the OS with only the features I listed above? What options can I disable or enable while still having a working system?
Having the Kernel very small is not important for Ubuntu, so maybe choosing Ubuntu is part of your problem. I would use as starting point what OpenWRT does. They do a good work making the Kernel small and it is easy to get started. OpenWrt Buildroot – Usage
try Linux From Scratch. It is a step by step approach on building a minimal Linux system from which you can evolve later on. http://www.linuxfromscratch.org/.
Use Gentoo Linux distribution - it's great for practicing on creation of Linux systems. Gentoo has excellent setup documentation, for example about configuring the kernel.
And Gentoo is a little easier and faster to setup than Linux From Scratch (LFS). If you want to go deeper, then LFS may be a good learning step too.

Does have SunOS,Aix,HP the signalfd(), eventfd() APIs?

I know the signalfd(), eventfd() apis in linux OS.
But, I can't find this api in other OS (SunOS, Aix, HP).
Is it only support in Linux??
Both the signalfd and eventfd APIs are linux specific.
If you're trying to write portable code; then you're better off sticking to the POSIX APIs. Bear in mind that there can be vagaries in the implementations between platforms.

What is a good barebones linux distro for beginner kernel development?

In my Operating Systems class we are looking to modify a Linux kernel with some simple system calls of our own in C.
What would be a good distro suited for this purpose? We don't need any frills, no GUI, a vanilla kernel, etc. The more basic the better.
I was able to modify the kernel pretty easily using a minimal Gentoo install.
Just install gentoo, follow the installation instructions, then:
$ emerge gentoo-sources
$ emerge emacs
$ cd /usr/src/linux
In my operating systems course last semester we used User Mode Linux, the big advantage being that when you hose the system, you can simply kill the process with no risk to the host environment.
Adding/Modifying system calls is tedious but trivial regardless of the kernel you use. However the 2.6 kernel is significantly more massive and complex, so if you're going to be modifying the code in a significant way the older kernels are easier to work with and much better documented. (ie: easier to find books and references)
Happy hacking :)
archlinux++
but really.. gentoo, slack, and arch are all more-or-less good choices
Arch Linux provides a great platform for kernel development that is also very functional. If you learn to use pacman, it will actually make testing your kernel modifications quite easily and provides the sources and tools in a sane manner.
I do think that if you are serious about learning linux and kernel hacking, doing a Linux From Scratch install should be on your list. It's a great distro/book and will let you build the platform for development yourself.
On all distributions, you can install the vanilla kernel.org sources instead of the distribution-related kernel packages, which is probably a good idea anyway when you want to do kernel development.
However, you'll be in trouble when you want to use any recent distribution with non-2.6 kernels, because they often build libc6 in a way that it cannot run with 2.4. Additionally, a lot of the guts of hardware management (like udev) require fairly recent kernels.
Apart from that, using Debian gives you a barebone system, and installing your own kernels is a breeze with kernel-package.
I wouldn't necessarily say any particular distro is geared towards kernel development as such, but if you want a traditional Linux distro that doesn't pile too much custom configuration stuff between you and the kernel, Slackware is a decent choice.
My suggestion is to grab the latest kernel. There will be more debugging features inside it than in an older kernel. Also, older kernels would pretty much look just as complex as the most recent to the newbie.
As for the distribution itself, you can't really go wrong. If all you want is to try some custom system calls, then grab whatever mainstream distribution which gives you a nice development environment. Then compile and try your customized glibc without installing it over the distro's.
When choosing a distro for kernel development, remember that it's the kernel you want to hack, not the distro itself. You will therefor want an easy distro that stays out of your way as much as possible. Ubuntu says out of the way fairly nicely.
IANAKH
A non-linux alternative is Geek OS, but this is very much aimed at the educational level, and is not a practical kernel. It is ultra-simple though.
well I have found one called "minix" it isn't really a linux distro, but it was made specifically for teaching, but if you can only use a linux distro, then it shouldn't matter, I am pretty sure all distros have the same kernel
Gentoo if you dont mind automated compilation (most people think that gentoo is Linux From Scratch => you have to do everything on your own).
Arch if you have slower computer (laptop).
Biggest advantage of these two is that they have very very good documentation and only installing Gentoo f.e. gives you basic knowledge about init system and what services has to run. If one copy&paste commands from guide it's worthless though (luckily handbook makes people think a bit, thus preventing kids from installing gentoo and taking over our neat #irc) :D

Resources