Month: October 2005

Remover arquivos com nomes estranhos

Já apareceu em seu sistema um arquivo com algum nome estranho que você não consegue deletar por nada neste mundo?

Arquivo com nome estranhos começando com alguma letra do alfabeto são facilmente removidas usando caracteres coringas como * e ?, mas o problema ocorre quando a primeira letra é um caracteres especial. No meu caso o arquivo chamava-se “-p”, e não poderia ser removido facilmente, pois qualquer tentativa de passar a primeira letra do arquivo era interpretado como parametro para o comando de remoção.

A solução encontrada é usar a informação do inode:

$ ls -i
439936 -rwxr–r– 1 alan alan 672 2005-10-07 21:35 -p

$ find . -inum 439936 -exec rm ‘{}’ \;

Este comando procura a partir do diretório atual o arquivo com o inode listado anteriormente, quando encontra, é executado (-exec) o comando rm ‘{}’, o ‘{}’ representa a lista de nome retornados pelo find.

Após verificar que o comando acima funciona, resolvi criar o arquivo novamente e substituir o rm ‘{}’ por echo ‘{}’, isto me retornou:
./-p

Então resolvi testar:
$ rm ./-p

Pronto, funcionou.

Conclusão, eu estava tendo apagar executando rm “-p”, rm \-p, rm *p, mas não testei rm ./-p, que poderia resolver o problema, de qualquer forma poderei usar o comando acima para apagar arquivos onde o rm ./arquivo não funcione.

Alan

Adicionando o netsnmpd no uClinux

Platform: Motorola 5272C3 eval board.
Kernel: 2.4.x
Config: vanilla configuration, with the exception of netsnmp added as
a network application and with openssl library built as
per the instructions on ucdot.org (for building openssl and
boa).

Steps:

1. download net-snmp-5.0.8.tar from www.net-snmp.org
2. create a directory uClinux-dist/user/netsnmp and put all the
tar files here (tar -xvf …). I had to copy the files up
a directory level as the tar file creates a -5.0.8 directory.
3. add netsnmp as a configuration option by adding the line

bool ‘net snmpd’ CONFIG_USER_NETSNMP_SNMPD

to config/config.in and altering the user/Makefile as well (it’s
obvious).
4. I ran configure in the netsnmp directory using the following
command:

./configure \
–target=m68k-elf-linux-gnu \
–with-cc=m68k-elf-gcc \
–with-ar=m68k-elf-ar \
–with-endianness=big \
–with-cflags=”-m5307 -DCONFIG_COLDFIRE -Os -g \
-fomit-frame-pointer -Dlinux -D__linux__ \
-Dunix -D__uClinux__ -DEMBED \
-I/home/bob/uClinux-dist/uClibc/include \
-L/home/bob/uClinux-dist/uClibc/lib/ -lm -lcrypt \
-fno-builtin -msep-data -Wl,-elf2flt \
-Wl,-move-rodata \
-nostartfiles /home/bob/uClinux-dist/lib/uClibc/lib/crt0.o \
-lc” \
–enable-mini-agent \
–disable-debugging \
–program-suffix=”” \
–includedir=”/home/bob/uClinux-dist/uClibc/include” \
–without-kmem-usage \
–with-transports=”UDP” \
–with-out-transports=”UDPIPv6 TCPIPv6 TCP Unix Callback
AAL5PVC IPX” \
–with-security-modules=”usm” \
–with-mib-modules=”mibII snmpv3mibs notification target” \
–with-out-mib-modules=”ucd_snmp agent_mibs agentx
utilities”

Its obvious where I’ve got the files, no?

After this runs, I had to do the following:

1. to netsnmp/include/net-snmp/net-snmp-config.h I had to add
two lines:

#define HAVE_STRERROR 1
#define HAVE_SETENV 1

2. to netsnmp/libsnmp/Makefile I had to add

snmpCallbackDomain.c

to the list of files defined for CSRCS

3. in netsnmp/Makefile I changed SUBDIRS and TESTDIRS to

#SUBDIRS = snmplib agent apps local man mibs
SUBDIRS = snmplib agent
#TESTDIRS = testing
TESTDIRS =

4. added romfs to netsnmp/Makefile

romfs:
$(ROMFSINST) agent/snmpd.gdp /bin/snmpd

5. created an snmpd.conf file in romfs/etc

6. fired the bad boy up via

snmpd -c /etc/snmp.conf -f &

Configurando a tecla “?” que não funciona no teclado ABNT2 após atualizar o XFree

Execute o xev para obter o código de varedura da tecla:
$ xev

KeyPress event, serial 30, synthetic NO, …
root 0x9f, subw 0x0, time 179329458, …
state 0x0, keycode 123 …

Como podemos ver o código (keycode) é 123, agora vamos definir como o X irá interpretar esta tecla. Mas antes precisamos descobrir qual é o símbolo usado para representar a tecla interrogação:

$ less /usr/X11R6/lib/X11/xkb/symbols/br | grep question
key <AB11> { [ slash, question ],
[ degree, questiondown ] };

Então AB11 representa a tecla de Interrogação, agora é só acrescentá-la no mapa de teclas abnt2 com o código que encontramos acima:

$ vi /usr/X11R6/lib/X11/xkb/keycodes/xfree86

// For brazilian ABNT2 keyboard. by Ricardo Y. Igarashi(iga@that.com.br)
xkb_keycodes “abnt2” {
include “xfree86(basic)”
<BKSL> = 94;
<AC12> = 51;
<KPPT> = 134;
<AB11> = 123;
};

Após reiniciar o X seu teclado funcionará corretamente.

Alan

Compilando o RTAI para o MCF5282

Descompactar rtai5282.tgz

$ cd /comum/uclinux
$ tar zxvf rtai5282.tgz
$ cd rtai5282/uClinux-dist-rtai
$ make clean
$ cd rtai-24.1.8

Editar o arquivo Makefile.modbuild mudando USER_LDFLAGS de:

USER_LDFLAGS := -elf2flt -L$(TOPDIR)/lxrt/lib

para:

USER_LDFLAGS :=-M -L$(TOPDIR)/lxrt/lib -lc

$ make clean
$ make ARCH=m68knommu CROSS_COMPILE=m68k-elf- LINUXDIR=”/comum/uclinux/rtai5282/uClinux-dist-rtai/linux-2.4.x” menuconfig
$ make dep
$ cd ..
$ make xconfig

Ative o suporte a módulo no kernel, para que os módulos do RTAI possam ser adicionados ao kernel.

$ make dep
$ make

Pronto