Skip to content

rename %ProgramFiles%

Wow, another entry covering some Windows oddity. One might think this OS is full of oddities :-) This time I tried to rename c:\program files because I wanted to mount another disk to c:\program files. Sure, lots of programs might be running from c:\program files, but when I stop all these programs, WindowsXP should still be able to boot and even start RDP to let me login, right? And so it did, with a few preparations made:
  • C:\Program Files cannot just be renamed - WindowsXP won't let you, it's some kind of magic special folde^Wdirectory. We'll use regedit to modify two keys:

    Set HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir to something else, e.g. "C:\Program Files2" While this gets exported as "%ProgramFiles%" via "ProgramFilesPath", we have to edit another key:

    Set HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\CommonFilesDir to something else, e.g. "C:\Program Files2\Common Files". We have to reboot to apply these changes, of course :-)

  • After the reboot, we should be able to rename c:\program files to something else. You might notice that our interim %ProgramFiles% directory got filled with a few directories - just ignore them. With our original c:\program files our of the way, we create an empty c:\program files, where we can now mount the other disk. Once this is done, we can start moving the our original c:\program files content (that we just moved out of the way) into our new c:\program files directory. While it's moving, we can set the registry keys we changed (see above) back to its original values.
Now reboot to get the registry settings applied and all should be well again - except that our c:\program files has now plenty of space :-)

cpio: Malformed number

This one time I have to deal with rpm packages and this happens:
$ rpm2cpio file.rpm | cpio -id
cpio: Malformed number
....and only garbage is being passed to cpio. Since RPM now comes with XZ/LZMA compression support, we have to prepare this for cpio until rpm2cpio will be fixed:
$ rpm2cpio file.rpm | lzma -d | cpio -id
7090 blocks

Extended Attributes and ACLs

Often enough I confuse them myself, so here's a little cheatsheet for you^Wme to remember:

ACLs

ACLs are extending the traditional permission model with a more fine-grained one.
  • - getfacl, setfacl - filesystem independen access control list manipulation
  • - chacl - an IRIX-compatibility command
$ chacl u::rw-,g::r--,o::r--,u:dummy:--x,m::r-x file.txt
$ chacl -l file.txt 
file.txt [u::rw-,u:dummy:--x,g::r--,m::r-x,o::r--]
$ su -c "cat ./file.txt" dummy 
cat: ./file.txt: Permission denied

$ setfacl -m u::rw-,g::---,o::---,u:dummy:r--,m::r-x file.txt
$ getfacl file.txt 
# file: file.txt
# owner: root
# group: root
user::rw-
user:dummy:r--
group::---
mask::r-x
other::---

EAs

Extended attributes are arbitrary name/value pairs which are associated with files or directories.
  • setfattr, getfattr - filesystem independent extended attribute manipulation
  • attr - aimed specifically at users of the XFS filesystem
$ attr -q -s foo -V 42 file.txt 
$ attr -g foo file.txt 
Attribute "foo" had a 3 byte value for file.txt:
42
$ setfattr -n user.bar -v 23 file.txt
$ getfattr -n user.bar file.txt
# file: file.txt
user.bar="23"

file attributes

These "file attributes" look like they were meant to be supported by the ext2/3/4 filesystems only. However, Btrfs, JFS and XFS support them as well, ReiserFS and Reiser4 do not. In fact, I haven't found a mount option for Reiser4 yet to support ACLs and EAs either :-\
# chattr +i file.txt 
# lsattr file.txt
----i-------------- file.txt
# rm -f file.txt 
rm: cannot remove `file.txt': Operation not permitted