This blog will be my notepad of things i learn , new programming language, tools , compilers etc.This blog is more of my penesive to see how much my understanding of things have evolved.
I have been trying to get the latest version of the linux-next. As you guys already know all the latest changes of all the subsystem trees are pulled regularly into the linux-next tree and this helps in detecting merge conflicts earlier.I had already mentioned how I would clone the linux next tree in here.
Now i was trying to pull the latest change into the linux-tree using the following command
Have you ever wondered why sending mails using git ends up in spam folder in your gmail mailbox. I was recently trying to send some patches of git to someone and i noticed that all the mails i sending using git-format0-mail ends up in my spam folder.
This was annoying and i wanted to make sure that it never happens again and so i digged ina bit.I was using my gmail account to send the mails using my account login and password.But still the mails ended up as spam.
This is because gmail is not able to make the channel secure using TLS/SSL autentication.The simple solution is to use a package called msmtp-mta.
You can install it by using
sudo apt-get install msmtp-mta
Now that you have installed tha package you need to configure it using the .msmtprc in your home directory
vi ~/.msmtprc
Now you need to configure your account details by modifying the necessary fields.
# Example for a user configuration file
# Set default values for all following accounts.
defaults
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
# My email service
account gmail
host smtp.gmail.com
port 587
from your@accountdetails.com
auth on
user your@accountdetails.com
password your@password
# Set a default account
account default : gmail
Now change the file permission so that no one can see it
chmod 600 .msmtprc
If you are using gmail, i strongly suggest you to use the 2 step autenticaion mechanisim as mentioned here.
This will make sure that you dont have to expose your gmail actual password and no other person can use it even if he sees it.
Now that you have all the mail configuration done you can use the git-format-patch as earlier without any changes as below
Sysfs is the commonly used method to export system information from the kernel space to the user space for specific devices.THe procfs is used to export the process specific information and the debugfs is used to used for exporting the debug information by the developer.
The sysfs is tied to the device driver model of the kernel.To more about device driver model see [1]
So lets start building a simple sysfs that we will export to the user space.
the following is the basic structure of any simple device driver
At the heart of the sysfs model is the Kobject.Kobject is the glue that binds the sysfs and the kernel.
In this example lets write a simple code that will add a directory and a file to the sysfs.The file will allow reading and writing data to the sysfs of a fixed size of 4096 bytes.
The first step is to create a directory into the /sys/kernel directory. Thiscan be done by adding the following line in the mymodule_init function
Dont forget to remove the kobject from the sysfs ,else the entry cannot be deleted untill the system is rebooted.
1
kobject_put(example_kobject);
Now compile the kernel module and load it using insmod and you will see the following entry
pradheep@PradheepVM:$ ls /sys/kernel/
.. kobject_example ..
The second step is creating the actual file attribute.There are loads of helper function that can be used to create the kobject attributes.They can be found in header file sysfs.h
To create a single file attribute we are going to use ‘sysfs_create_file’.One can use another function ‘ sysfs_create_group ‘ to create a group of attributes.
1
2
3
4
error=sysfs_create_file(example_kobject,&foo_attribute.attr);if(error){pr_debug("failed to create the foo file in /sys/kernel/kobject_example \n");}
in the above code the second argument foo_attribute.attr helps in registering the callback methods that is needed to be used when the particular file example_kobject is accessed. It can be defined using the macro __ATTR as below
what the above code essentially does is as set the corresponding attribute name, permission and the callback methods to be used when the file foo is accessed.
The third step is to use a define what needs to be done when the particular file/attribute foo is accessed. In this case we expect the user would allow user to write an integer value and when read we give back the integer value that was written earlier.
The full implementation is as follows
We can change the above code to store any value (upto 4096 bytes) by just changing the logic as follows.