Is there some smart way of reading content of file by lines (in python) if this file kinda acts like buffer?
To be more specific I'm implementing simple firewall as kernel module which communicates with user space application through procfs. When userspace application requests to print all firewall rules procf_read function is called and all rules are stored in buffer which is later copied to user (copy_to_user
func). If I use simple for loop to read file by lines it loops over file and prints lines just fine (let's say there are 3 of them) but then it loops over printing same lines over and over until whole buffer is read (my guess). I would like to print just these 3 lines ideally without inserting extra symbol to file's end to simulate 'EOF' and then detecting it in user space (python). I'm thinking of reading file by bytes but how to get number of bytes to read in C's fread()
way?