[so2] [Tema4] File command

Rares Folea raresfolea97 at gmail.com
Sat May 9 13:48:01 EEST 2020


Buna ziua!

Am descoperit un comportament neasteptat la rularea comenzii file,
in sensul utilizarii acesteia in teste[1].
Desi fisierul este inexistent, comanda **file** intoarce codul de retur 0.

Experimentul facut a fost urmatorul:

root at qemux86:~/skels/assignments/4-stp# insmod af_stp.ko

root at qemux86:~/skels/assignments/4-stp# file /proc/net/stp_stats
/proc/net/stp_stats: empty

root at qemux86:~/skels/assignments/4-stp# echo $?

0

root at qemux86:~/skels/assignments/4-stp# cat /proc/net/stp_stats

RxPkts  HdrErr  CsumErr NoSock  NoBuffs TxPkts

0       0       0       0       0       0

root at qemux86:~/skels/assignments/4-stp# echo $?

0

root at qemux86:~/skels/assignments/4-stp# rmmod af_stp

NET: Unregistered protocol family 19

root at qemux86:~/skels/assignments/4-stp# file /proc/net/stp_stats

/proc/net/stp_stats: cannot open `/proc/net/stp_stats' (No such file or
direct)
root at qemux86:~/skels/assignments/4-stp# echo $?

0

root at qemux86:~/skels/assignments/4-stp# cat /proc/net/stp_stats

cat: can't open '/proc/net/stp_stats': No such file or directory

root at qemux86:~/skels/assignments/4-stp# echo $?

1

Ca urmare, testul test_proc_entry_inexistent_after_rmmod pica mereu,
deoarece codul de retur este 0 mereu.


[1]
https://github.com/linux-kernel-labs/linux/blob/master/tools/labs/templates/assignments/4-stp/checker/_test/stp_test.c#L145
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/so2/attachments/20200509/55c8dac8/attachment.html>


More information about the so2 mailing list