Skip to content

Instantly share code, notes, and snippets.

View lorenzo-stoakes's full-sized avatar

Lorenzo Stoakes lorenzo-stoakes

View GitHub Profile
@lorenzo-stoakes
lorenzo-stoakes / memfd_repro.c
Created November 3, 2023 14:42
mmap F_SEAL_WRITE memfd read-only
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
int main()
{
const long page_size = sysconf(_SC_PAGESIZE);
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/userfaultfd.h>
#include <unistd.h>
#define TARGET_PTR ((void *)0x700000000000UL)
@lorenzo-stoakes
lorenzo-stoakes / watch.sh
Created February 11, 2023 10:33
inotify script for mm-book LaTeX build
#!/bin/bash
set -e; set -o pipefail
# Thanks to https://stackoverflow.com/a/246128
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"
cd ${SCRIPT_DIR}
[[ -z $1 ]] || ${SCRIPT_DIR}/build.sh $1
# Now watch for file changes.
@lorenzo-stoakes
lorenzo-stoakes / buildLinux.sh
Last active August 29, 2015 14:16
Custom Kernel Build Script
#!/bin/bash
set -o errexit
# Ref: http://stackoverflow.com/a/6481016
CORES=$(grep -c ^processor /proc/cpuinfo)
pushd ~/linux
make mrproper
@lorenzo-stoakes
lorenzo-stoakes / sortFun.go
Created January 28, 2015 00:00
A simple bit of code for comparing comparison count between different sorting algos
package main
import (
"fmt"
"math"
"math/rand"
"sort"
"time"
)
@lorenzo-stoakes
lorenzo-stoakes / devmapper.diff
Last active December 26, 2015 07:49
Patch for docker v0.7.0-rc4 to allow use on a 32-bit device, also fix missing arg to MountDevices().
diff --git a/devmapper/devmapper.go b/devmapper/devmapper.go
index eae4224..36fd985 100644
--- a/devmapper/devmapper.go
+++ b/devmapper/devmapper.go
@@ -1,6 +1,7 @@
package devmapper
/*
+#cgo CFLAGS: -D_FILE_OFFSET_BITS=64
#cgo LDFLAGS: -L. -ldevmapper
package test
import runtime "runtime"
type Foo interface {
Bar() *interface {
Bar() *interface {
Bar() *interface {
Bar() DotDotDot
Baz() *interface {
package test
import runtime "runtime"
type Foo interface {
Bar() *interface {
Bar() *interface {
Bar() DotDotDot
Baz() *interface {
Bar() DotDotDot
package test
import runtime "runtime"
type Foo interface {
Bar() *interface {
Bar() DotDotDot
Baz() *interface {
Bar() DotDotDot
Baz() DotDotDot