static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
{
 struct fs_struct *fs = current->fs;
 if (clone_flags & CLONE_FS) {
  /* tsk->fs is already what we want */
  spin_lock(&fs->lock);
  if (fs->in_exec) {
   spin_unlock(&fs->lock);
   return -EAGAIN;
  }
  fs->users++;
  spin_unlock(&fs->lock);
  return 0;
 }
 tsk->fs = copy_fs_struct(fs);
 if (!tsk->fs)
  return -ENOMEM;
 return 0;
}
 
struct fs_struct *copy_fs_struct(struct fs_struct *old)
{
 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
 /* We don't need to lock fs - think why ;-) */
 if (fs) {
  fs->users = 1;
  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;
}


 

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6