Kernel File System API: unmarsh_fs_struct,

Source: Internet
Author: User

Kernel File System API: unmarsh_fs_struct,

Kernel File System API: unmarsh_fs_struct

Int unshare_fs_struct (void) is used to set a new value with the fs_struct of the current task, so that the source code of the copy is not shared. The source code analysis is as follows: int unshare_fs_struct (void) {struct fs_struct; # apply for a new fs_structstruct fs_struct * new_fs = copy_fs_struct (fs); int kill; # if the newly applied fs_struct is null, exit if (! New_fs) return-ENOMEM; task_lock (current); spin_lock (& fs-> lock); kill =! -- Fs-> users; # Set the newly applied fs_structcurrent-> fs = new_fs; spin_unlock (& fs-> lock); task_unlock (current); if (kill) for the current task) implementation of struct (fs); return 0;} copy_fs_struct is as follows: struct fs_struct * struct (struct fs_struct * old) {# apply for fs_struct * fs = struct (fs_cache, GFP_KERNEL ); /* We don't need to lock fs-think why;-) */# assign the initial value if (fs) {fs-> users = 1 to the newly applied fs_struct; fs-> in_exec = 0; spin_lock_init (& fs-> lock); seqcount_init (& fs-> seq); fs-> umask = old-> umask; spin_lock (& old-> lock); fs-> root = old-> root; path_get (& fs-> root); fs-> pwd = old-> pwd; path_get (& fs-> pwd); spin_unlock (& old-> lock);} return fs ;}

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.