Category Archives: Operation Systems

C print pointers correctly

What’s the proper use of printf to display pointers padded with 0s

#include <inttypes.h>
#include <stdint.h>

printf("0x%012" PRIxPTR "\n", (uintptr_t) ptr);

printf("%012p", ptr);
warning: '0' flag used with ‘%p’ gnu_printf format [-Wformat]

printf("0x%012X", ptr);
warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘XXX’ [-Wformat]

Ubuntu: disable scrollbar overlay

How do I disable overlay scrollbars?

export LIBOVERLAY_SCROLLBAR=0

oder

export LIBOVERLAY_SCROLLBAR=0

oder

sudo apt-get remove overlay-scrollbar liboverlay-scrollbar

oder

Ubuntu 12.04
gsettings set org.gnome.desktop.interface ubuntu-overlay-scrollbars false
gsettings reset org.gnome.desktop.interface ubuntu-overlay-scrollbars

Ubuntu 12.10
gsettings set com.canonical.desktop.interface scrollbar-mode normal
gsettings reset com.canonical.desktop.interface scrollbar-mode

Start Industrial HiVision and Services

********************************************************************************
*
* Industrial HiVision 04.4.00 is now installed and ready for use.
*
* the services can be started/stopped by the root user with the command
*      /etc/init.d/ihivision04.4.00 start|stop
* the graphical application can be started by any user with the command
*      /opt/ihivision04400/bin/HiVision
*
********************************************************************************

Ubuntu Natty: Kernel kombilieren

How to compile a new Ubuntu 11.04 (Natty) kernel

sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r) 
apt-get source linux-image-$(uname -r)
chmod +x debian/scripts/*
chmod +x debian/scripts/misc/*

cp debian.master/config/amd64/config.flavour.generic debian.master/config/amd64/config.flavour.bachi
fakeroot debian/rules clean
debian/rules updateconfigs 

debian/rules editconfigs

Do you want to edit config: amd64/config.flavour.bachi? [Y/n] Y

cp debian.master/abi/2.6.38-15.65/i386/generic debian.master/abi/2.6.38-15.65/i386/bachi
cp debian.master/abi/2.6.38-15.65/i386/generic.modules debian.master/abi/2.6.38-15.65/i386/bachi.modules
cp debian.master/control.d/vars.generic debian.master/control.d/vars.bachi

File: debian.master/etc/getabis
getall amd64 generic server virtual bachi

File: debian.master/rules.d/i386.mk
flavours        = generic server virtual bachi

skipabi=true skipmodule=true fakeroot debian/rules binary-indep
skipabi=true skipmodule=true fakeroot debian/rules binary-perarch
skipabi=true skipmodule=true fakeroot debian/rules binary-bachi
oder
AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-generic

nur wenn Debian-Weg:
sudo update-initramfs -k version -c
sudo grub-mkconfig -o /boot/grub/grub.cfg 

NFS Mount

FreeBSD

# NFS
rpcbind_enable="YES"
nfs_server_enable="YES"
mountd_enable="YES"
mountd_flags="-r"
rpc_statd_enable="YES"
rpc_lockd_enable="YES"
/usr/home/bachi /nfsroot	-mapall=bachi	10.0.0.252 160.85.232.173
$ service nfsd stop; service mountd stop; service rpcbind stop
$ service nfsd start
$ /etc/rc.d/mountd reload

FAQ

Aug  3 15:23:38 virtualbox mountd[1138]: bad exports list line /usr/home/bachi /nfsroot
Aug  3 15:25:47 virtualbox mountd[1139]: mount request denied from 172.16.0.1 for /usr/home/bachi
Apr 25 08:06:13 gateway mountd[1983]: can't change attributes for /usr/home/bachi: Invalid radix node head, rn: 0 0xfffff80007a16700

> However, 2 exports in that file are causing problems. When I restart
> mountd, they log lines like:
> 
> Jan 12 16:01:14 solfertje mountd[99349]: can't change attributes for
> /usr/home/smb: Invalid radix node head, rn: 0 0xfffffe0023e1c600
> What does that message mean? Where do I look to fix this?
 
Are these paths (/usr/home/smb and /usr/home/vhosts/django) separate file
systems on the server from the others?

If they are on the same server file system as one of the other entries,
then the paths need to be added to that entry. You cannot have multiple
entries for the same server file system and exported host/subnet.

Linux

$ sudo apt-get install nfs-kernel-server
/home/andreas/projects   192.168.1.20(rw,sync,no_root_squash,no_subtree_check)
$ sudo apt-get install nfs-common
$ sudo mount 192.168.1.5:/home/andreas/projects /home/ines/projects

NAT Routing on Linux

Linux configure Network Address Translation or NAT

# echo "1" > /proc/sys/net/ipv4/ip_forward
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -L
####### ROUTER / GATEWAY #######

# Flush rules from iptables
iptables -F

# Flush rules from nat table in iptables
iptables -t nat -F

# IP Forwarding (global)
echo 1 > /proc/sys/net/ipv4/ip_forward
# oder (für jedes Interface einzeln)
echo 1 > /proc/sys/net/ipv4/conf/eth0/forwarding

# Regeln definieren
INET_IF=eth0
LOCAL_IF=eth4
iptables -t nat -A POSTROUTING -o $INET_IF -j MASQUERADE
iptables -A FORWARD -i $INET_IF -o $LOCAL_IF -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $LOCAL_IF -o $INET_IF -j ACCEPT

# Überprüfen
iptables -t nat -v --list
iptables -v --list

#######  CLIENT #######

GATEWAY=192.168.1.1
route add default gw $GATEWAY