Register_filesystem and unregister_filesystem of Kernel File System APIs,

Source: Internet
Author: User

Register_filesystem and unregister_filesystem of Kernel File System APIs,

Register_filesystem and unregister_filesystem of Kernel File System APIs

Int register_filesystem (struct file_system_type * fs) is used to register a new file system. The source code analysis is as follows: int register_filesystem (struct file_system_type * fs) {int res = 0; struct file_system_type * p; # The file system name cannot contain '. 'bug _ ON (strchr (fs-> name ,'. '); # fs-> next is not null, busyif (fs-> next) return-EBUSY; # the file system is in a list, write_lock (& file_systems_lock); # Check whether the file system of the parameter has been registered. If it has been registered, busy is returned, responsible for modifying the file system p = find_filesystem (fs-> name, st Rlen (fs-> name); if (* p) res =-EBUSY; else * p = fs; write_unlock (& file_systems_lock); return res ;} from the find_filesystem function, we can know that all registered file systems are in the file_systems linked list. It mainly uses name to match whether the file system has registered static struct file_system_type ** find_filesystem (const char * name, unsigned len) {struct file_system_type ** p; for (p = & file_systems; * p; p = & (* p)-> next) # traverse the list of registered file systems and use name to match if (strncmp (* p)-> name, name, len) = 0 &&! (* P)-> name [len]) break; return p;} corresponds to unregister_filesystem, which cancels a file system int unregister_filesystem (struct file_system_type * fs) {struct file_system_type ** tmp; write_lock (& file_systems_lock); # Use the tmp variable to point to the linked list tmp = & file_systems; while (* tmp) of the total file system) {# When the comparison pointer is released and equal, delete this node from file_systems if (fs = * tmp) {* tmp = fs-> next; fs-> next = NULL; write_unlock (& file_systems_lock); synchronize_rcu (); return 0;} tmp = & (* tmp)-> next;} write_unlock (& file_systems_lock ); return-EINVAL ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.