Recentemente, eu estava usando mv
para mover uma grande quantidade de arquivos do meu disco rígido para uma unidade flash. Esqueci de adicionar uma sinalização detalhada, então não tinha ideia de "onde" a movimentação estava e quantas transferências restavam.
Eu encontrei o utilitário strace
e decidi usá-lo no meu processo de mv. Usando ps -ef | grep mv
, consegui encontrar o pid do processo e, em seguida, executei strace -p [PID]
. Aqui está uma amostra do que recebi:
write(4, "5fcntl(3, F_GETFD) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl(3, F_GETFL) = 0x38800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_NOFOLLOW)
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fcntl(3, F_DUPFD, 3) = 4
fcntl(4, F_GETFD) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
getdents64(3, /* 4 entries */, 32768) = 120
getdents64(3, /* 0 entries */, 32768) = 0
close(3) = 0
newfstatat(4, "The Pick of Destiny", {st_mode=S_IFDIR|0755, st_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0
openat(4, "The Pick of Destiny", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = 3
fcntl(3, F_GETFD) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl(3, F_GETFL) = 0x38800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_NOFOLLOW)
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fcntl(3, F_DUPFD, 3) = 5
fcntl(5, F_GETFD) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
getdents64(3, /* 22 entries */, 32768) = 1008
getdents64(3, /* 0 entries */, 32768) = 0
close(3) = 0
write(4, "5fcntl(3, F_GETFD) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl(3, F_GETFL) = 0x38800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_NOFOLLOW)
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fcntl(3, F_DUPFD, 3) = 4
fcntl(4, F_GETFD) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
getdents64(3, /* 4 entries */, 32768) = 120
getdents64(3, /* 0 entries */, 32768) = 0
close(3) = 0
newfstatat(4, "The Pick of Destiny", {st_mode=S_IFDIR|0755, st_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0
openat(4, "The Pick of Destiny", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = 3
fcntl(3, F_GETFD) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl(3, F_GETFL) = 0x38800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_NOFOLLOW)
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fcntl(3, F_DUPFD, 3) = 5
fcntl(5, F_GETFD) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
getdents64(3, /* 22 entries */, 32768) = 1008
getdents64(3, /* 0 entries */, 32768) = 0
close(3) = 0
%pre%s4%pre%%pre%%pre%%pre%09%pre%%pre%17%pre%%pre%0H:0xgM74\"3"..., 32768) = 32768
read(3, "19H\r7571JL)01C\t3(4310;{45nh@F"..., 32768) = 32768
write(4, "19H\r7571JL)01C\t3(4310;{45nh@F"..., 32768) = 32768
read(3, "ZK1234@752$47];5540d57P7*46646"..., 32768) = 32768
write(4, "ZK1234@752$47];5540d57P7*46646"..., 32768) = 32768
read(3, ".156541{c,$6]421\"4K446677m"..., 32768) = 32768
s4%pre%%pre%%pre%%pre%09%pre%%pre%17%pre%%pre%0H:0xgM74\"3"..., 32768) = 32768
read(3, "19H\r7571JL)01C\t3(4310;{45nh@F"..., 32768) = 32768
write(4, "19H\r7571JL)01C\t3(4310;{45nh@F"..., 32768) = 32768
read(3, "ZK1234@752$47];5540d57P7*46646"..., 32768) = 32768
write(4, "ZK1234@752$47];5540d57P7*46646"..., 32768) = 32768
read(3, ".156541{c,$6]421\"4K446677m"..., 32768) = 32768
e depois alguns:
%pre%
Então, o que exatamente o strace me dá? Estas chamadas do kernel são? Se eles são, o que eles significam (eu sei o que ler e escrever, mas quais são esses números)?
Pergunta de bônus: Existe uma maneira de eu ver algo "abaixo" do que o strace me mostra? CPU chamadas talvez?