亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cp.c

?? 《Linux應用開發技術詳解》附書光盤中的例程。
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* cp.c  -- file copying (main routines)
   Copyright (C) 89, 90, 91, 1995-2002 Free Software Foundation.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

   Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering. */

#ifdef _AIX
 #pragma alloca
#endif

#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <assert.h>
#include <getopt.h>

#include "system.h"
#include "argmatch.h"
#include "backupfile.h"
#include "copy.h"
#include "cp-hash.h"
#include "error.h"
#include "dirname.h"
#include "path-concat.h"
#include "quote.h"
#include "acl.h"

#define ASSIGN_BASENAME_STRDUPA(Dest, File_name)	\
  do							\
    {							\
      char *tmp_abns_;					\
      ASSIGN_STRDUPA (tmp_abns_, (File_name));		\
      strip_trailing_slashes (tmp_abns_);		\
      Dest = base_name (tmp_abns_);			\
    }							\
  while (0)

/* The official name of this program (e.g., no `g' prefix).  */
#define PROGRAM_NAME "cp"

#define AUTHORS N_ ("Torbjorn Granlund, David MacKenzie, and Jim Meyering")

#ifndef _POSIX_VERSION
uid_t geteuid ();
#endif

/* Used by do_copy, make_path_private, and re_protect
   to keep a list of leading directories whose protections
   need to be fixed after copying. */
struct dir_attr
{
  mode_t mode;
  int mode_valid;
  int slash_offset;
  struct dir_attr *next;
};

/* For long options that have no equivalent short option, use a
   non-character as a pseudo short option, starting with CHAR_MAX + 1.  */
enum
{
  COPY_CONTENTS_OPTION = CHAR_MAX + 1,
  NO_PRESERVE_ATTRIBUTES_OPTION,
  PARENTS_OPTION,
  PRESERVE_ATTRIBUTES_OPTION,
  REPLY_OPTION,
  SPARSE_OPTION,
  STRIP_TRAILING_SLASHES_OPTION,
  TARGET_DIRECTORY_OPTION,
  UNLINK_DEST_BEFORE_OPENING
};

/* Initial number of entries in each hash table entry's table of inodes.  */
#define INITIAL_HASH_MODULE 100

/* Initial number of entries in the inode hash table.  */
#define INITIAL_ENTRY_TAB_SIZE 70

/* The invocation name of this program.  */
char *program_name;

/* If nonzero, the command "cp x/e_file e_dir" uses "e_dir/x/e_file"
   as its destination instead of the usual "e_dir/e_file." */
static int flag_path = 0;

/* Remove any trailing slashes from each SOURCE argument.  */
static int remove_trailing_slashes;

static char const *const sparse_type_string[] =
{
  "never", "auto", "always", 0
};

static enum Sparse_type const sparse_type[] =
{
  SPARSE_NEVER, SPARSE_AUTO, SPARSE_ALWAYS
};

/* Valid arguments to the `--reply' option. */
static char const* const reply_args[] =
{
  "yes", "no", "query", 0
};

/* The values that correspond to the above strings. */
static int const reply_vals[] =
{
  I_ALWAYS_YES, I_ALWAYS_NO, I_ASK_USER
};

/* The error code to return to the system. */
static int exit_status = 0;

static struct option const long_opts[] =
{
  {"archive", no_argument, NULL, 'a'},
  {"backup", optional_argument, NULL, 'b'},
  {"copy-contents", no_argument, NULL, COPY_CONTENTS_OPTION},
  {"dereference", no_argument, NULL, 'L'},
  {"force", no_argument, NULL, 'f'},
  {"interactive", no_argument, NULL, 'i'},
  {"link", no_argument, NULL, 'l'},
  {"no-dereference", no_argument, NULL, 'P'},
  {"no-preserve", required_argument, NULL, NO_PRESERVE_ATTRIBUTES_OPTION},
  {"one-file-system", no_argument, NULL, 'x'},
  {"parents", no_argument, NULL, PARENTS_OPTION},
  {"path", no_argument, NULL, PARENTS_OPTION},   /* Deprecated.  */
  {"preserve", optional_argument, NULL, PRESERVE_ATTRIBUTES_OPTION},
  {"recursive", no_argument, NULL, 'R'},
  {"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
  {"reply", required_argument, NULL, REPLY_OPTION},
  {"sparse", required_argument, NULL, SPARSE_OPTION},
  {"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
  {"suffix", required_argument, NULL, 'S'},
  {"symbolic-link", no_argument, NULL, 's'},
  {"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION},
  {"update", no_argument, NULL, 'u'},
  {"verbose", no_argument, NULL, 'v'},
  {"version-control", required_argument, NULL, 'V'}, /* Deprecated. FIXME. */
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {NULL, 0, NULL, 0}
};

void
usage (int status)
{
  if (status != 0)
    fprintf (stderr, _("Try `%s --help' for more information.\n"),
	     program_name);
  else
    {
      printf (_("\
Usage: %s [OPTION]... SOURCE DEST\n\
  or:  %s [OPTION]... SOURCE... DIRECTORY\n\
  or:  %s [OPTION]... --target-directory=DIRECTORY SOURCE...\n\
"),
	      program_name, program_name, program_name);
      fputs (_("\
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
\n\
"), stdout);
      fputs (_("\
Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
      fputs (_("\
  -a, --archive                same as -dpR\n\
      --backup[=CONTROL]       make a backup of each existing destination file\n\
  -b                           like --backup but does not accept an argument\n\
      --copy-contents          copy contents of special files when recursive\n\
  -d                           same as --no-dereference --preserve=link\n\
"), stdout);
      fputs (_("\
      --no-dereference         never follow symbolic links\n\
  -f, --force                  if an existing destination file cannot be\n\
                                 opened, remove it and try again\n\
  -i, --interactive            prompt before overwrite\n\
  -H                           follow command-line symbolic links\n\
"), stdout);
      fputs (_("\
  -l, --link                   link files instead of copying\n\
  -L, --dereference            always follow symbolic links\n\
  -p                           same as --preserve=mode,ownership,timestamps\n\
      --preserve[=ATTR_LIST]   preserve the specified attributes (default:\n\
                                 mode,ownership,timestamps), if possible\n\
                                 additional attributes: links, all\n\
"), stdout);
      fputs (_("\
      --no-preserve=ATTR_LIST  don't preserve the specified attributes\n\
      --parents                append source path to DIRECTORY\n\
  -P                           same as `--no-dereference'\n\
"), stdout);
      fputs (_("\
  -R, -r, --recursive          copy directories recursively\n\
      --remove-destination     remove each existing destination file before\n\
                                 attempting to open it (contrast with --force)\n\
"), stdout);
      fputs (_("\
      --reply={yes,no,query}   specify how to handle the prompt about an\n\
                                 existing destination file\n\
      --sparse=WHEN            control creation of sparse files\n\
      --strip-trailing-slashes remove any trailing slashes from each SOURCE\n\
                                 argument\n\
"), stdout);
      fputs (_("\
  -s, --symbolic-link          make symbolic links instead of copying\n\
  -S, --suffix=SUFFIX          override the usual backup suffix\n\
      --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY\n\
"), stdout);
      fputs (_("\
  -u, --update                 copy only when the SOURCE file is newer\n\
                                 than the destination file or when the\n\
                                 destination file is missing\n\
  -v, --verbose                explain what is being done\n\
  -x, --one-file-system        stay on this file system\n\
"), stdout);
      fputs (HELP_OPTION_DESCRIPTION, stdout);
      fputs (VERSION_OPTION_DESCRIPTION, stdout);
      fputs (_("\
\n\
By default, sparse SOURCE files are detected by a crude heuristic and the\n\
corresponding DEST file is made sparse as well.  That is the behavior\n\
selected by --sparse=auto.  Specify --sparse=always to create a sparse DEST\n\
file whenever the SOURCE file contains a long enough sequence of zero bytes.\n\
Use --sparse=never to inhibit creation of sparse files.\n\
\n\
"), stdout);
      fputs (_("\
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\
The version control method may be selected via the --backup option or through\n\
the VERSION_CONTROL environment variable.  Here are the values:\n\
\n\
"), stdout);
      fputs (_("\
  none, off       never make backups (even if --backup is given)\n\
  numbered, t     make numbered backups\n\
  existing, nil   numbered if numbered backups exist, simple otherwise\n\
  simple, never   always make simple backups\n\
"), stdout);
      fputs (_("\
\n\
As a special case, cp makes a backup of SOURCE when the force and backup\n\
options are given and SOURCE and DEST are the same name for an existing,\n\
regular file.\n\
"), stdout);
      printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
    }
  exit (status);
}

/* Ensure that the parent directories of CONST_DST_PATH have the
   correct protections, for the --parents option.  This is done
   after all copying has been completed, to allow permissions
   that don't include user write/execute.

   SRC_OFFSET is the index in CONST_DST_PATH of the beginning of the
   source directory name.

   ATTR_LIST is a null-terminated linked list of structures that
   indicates the end of the filename of each intermediate directory
   in CONST_DST_PATH that may need to have its attributes changed.
   The command `cp --parents --preserve a/b/c d/e_dir' changes the
   attributes of the directories d/e_dir/a and d/e_dir/a/b to match
   the corresponding source directories regardless of whether they
   existed before the `cp' command was given.

   Return 0 if the parent of CONST_DST_PATH and any intermediate
   directories specified by ATTR_LIST have the proper permissions
   when done, otherwise 1. */

static int
re_protect (const char *const_dst_path, int src_offset,
	    struct dir_attr *attr_list, const struct cp_options *x)
{
  struct dir_attr *p;
  char *dst_path;		/* A copy of CONST_DST_PATH we can change. */
  char *src_path;		/* The source name in `dst_path'. */
  uid_t myeuid = geteuid ();
  mode_t umask_kill = ~umask (0);

  dst_path = (char *) alloca (strlen (const_dst_path) + 1);
  strcpy (dst_path, const_dst_path);
  src_path = dst_path + src_offset;

  for (p = attr_list; p; p = p->next)
    {
      struct stat src_sb;

      dst_path[p->slash_offset] = '\0';

      if ((*(x->xstat)) (src_path, &src_sb))
	{
	  error (0, errno, _("failed to get attributes of %s"),
		 quote (src_path));
	  return 1;
	}

      /* Adjust the times (and if possible, ownership) for the copy.
	 chown turns off set[ug]id bits for non-root,
	 so do the chmod last.  */

      if (x->preserve_timestamps)
	{
	  struct utimbuf utb;

	  /* There's currently no interface to set file timestamps with
	     better than 1-second resolution, so discard any fractional
	     part of the source timestamp.  */

	  utb.actime = src_sb.st_atime;
	  utb.modtime = src_sb.st_mtime;

	  if (utime (dst_path, &utb))
	    {
	      error (0, errno, _("failed to preserve times for %s"),
		     quote (dst_path));
	      return 1;
	    }
	}

      if (x->preserve_ownership)
	{
	  /* If non-root uses -p, it's ok if we can't preserve ownership.
	     But root probably wants to know, e.g. if NFS disallows it,
	     or if the target system doesn't support file ownership.  */
	  if (chown (dst_path, src_sb.st_uid, src_sb.st_gid)
	      && ((errno != EPERM && errno != EINVAL) || myeuid == 0))
	    {
	      error (0, errno, _("failed to preserve ownership for %s"),
		     quote (dst_path));
	      return 1;
	    }
	}

      if (x->preserve_mode)
	{
	  if (copy_acl (src_path, dst_path, src_sb.st_mode))
	    return 1;
	}
      else if (p->mode_valid)
	{
	  if (chmod (dst_path, p->mode))
	    {
	      error (0, errno, _("failed to preserve permissions for %s"),
		     quote (dst_path));
	      return 1;
	    }
	}

      dst_path[p->slash_offset] = '/';
    }
  return 0;
}

/* Ensure that the parent directory of CONST_DIRPATH exists, for
   the --parents option.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区二区在线观看视频| 日本在线不卡视频| 舔着乳尖日韩一区| 在线播放国产精品二区一二区四区| 日韩精品资源二区在线| 日韩在线一二三区| 日韩美女在线视频| 欧美一级片在线看| 国产精品资源站在线| 国产天堂亚洲国产碰碰| 成人av在线播放网站| 自拍偷拍国产亚洲| 在线91免费看| 日韩欧美一级在线播放| 日韩一级免费一区| 成人美女在线观看| 日本美女一区二区| 九九**精品视频免费播放| 国产精品沙发午睡系列990531| 一本色道久久加勒比精品 | 国产视频一区在线播放| 26uuu久久天堂性欧美| 99亚偷拍自图区亚洲| 亚洲成人精品一区| 久久久国产综合精品女国产盗摄| 欧美日韩午夜在线| 91.成人天堂一区| 久久久精品欧美丰满| 中文字幕亚洲成人| 久久综合国产精品| 国产精品亲子乱子伦xxxx裸| 一区二区在线观看免费视频播放| 久久日韩粉嫩一区二区三区| 综合久久一区二区三区| 日韩中文欧美在线| jlzzjlzz亚洲日本少妇| 欧美三级电影在线观看| 久久精品一区二区三区四区| 一区二区三区中文字幕电影| 欧美国产精品一区二区| 日韩女优毛片在线| 国产精品另类一区| 日韩一区二区视频在线观看| 欧美韩国日本不卡| 亚洲国产精品人人做人人爽| 亚洲人快播电影网| 亚洲区小说区图片区qvod| 免费三级欧美电影| 日本不卡中文字幕| av电影在线观看一区| 精品sm捆绑视频| 久久午夜电影网| 亚洲va韩国va欧美va| 成人国产在线观看| 日韩欧美成人午夜| 亚洲超碰97人人做人人爱| 99热精品一区二区| 欧美精品一区二区三区在线| 婷婷开心久久网| 欧洲另类一二三四区| 欧美日韩在线播放一区| 国产精品久久久久久久岛一牛影视 | 欧美日韩综合在线| 亚洲欧洲精品天堂一级| 国产一区91精品张津瑜| 国产成人精品www牛牛影视| 成人a级免费电影| 日韩欧美激情四射| 日韩av在线发布| 欧美无乱码久久久免费午夜一区| 欧美日韩国产天堂| 日韩女优视频免费观看| 偷拍与自拍一区| 欧美日韩免费观看一区三区| 亚洲精品久久7777| 色先锋aa成人| 亚洲精品精品亚洲| 日本丶国产丶欧美色综合| 欧美日韩国产综合久久| 一区二区三区.www| 欧美日韩在线播放三区| 亚洲成人av一区二区| 欧美日韩综合不卡| 石原莉奈在线亚洲三区| 日韩亚洲欧美在线观看| 日本视频中文字幕一区二区三区| 欧美福利视频导航| 久久电影网站中文字幕| 91视频免费播放| 精品日产卡一卡二卡麻豆| 国产欧美一区二区三区网站| 亚洲国产三级在线| 欧美日韩在线一区二区| 日本v片在线高清不卡在线观看| 正在播放亚洲一区| 国产在线麻豆精品观看| 欧美一a一片一级一片| 亚洲成年人网站在线观看| 9191久久久久久久久久久| 精品一区二区三区免费观看| 国产精品久久久久影视| 色妹子一区二区| 日韩精品电影一区亚洲| 精品日韩在线观看| 99久久精品国产一区二区三区| 欧美大胆一级视频| 白白色 亚洲乱淫| 天天色天天操综合| 国产婷婷一区二区| 色妹子一区二区| 国内国产精品久久| 综合色中文字幕| 欧美一区二区精品在线| 丁香天五香天堂综合| 精品国产伦理网| 日本精品一级二级| 激情欧美日韩一区二区| 亚洲综合在线免费观看| 国产亚洲精品超碰| 欧美精品日韩精品| av电影在线不卡| 韩国女主播一区| 午夜欧美在线一二页| 中文字幕在线不卡一区二区三区| 日韩欧美国产一区二区在线播放| 91在线无精精品入口| 看片的网站亚洲| 亚洲一级电影视频| 欧美日韩免费不卡视频一区二区三区| 国产呦精品一区二区三区网站| 亚洲123区在线观看| 中文字幕在线不卡一区| 久久久久国产免费免费| 欧美一二三四区在线| 在线观看国产一区二区| 成人av网站大全| 风间由美一区二区三区在线观看 | 欧洲亚洲精品在线| 99免费精品视频| 国模大尺度一区二区三区| 午夜成人在线视频| 亚洲美女视频一区| 国产精品欧美一级免费| 久久久噜噜噜久久人人看 | 久久免费视频一区| 欧美一区二区三区在| 欧美日韩国产一二三| 欧美三级资源在线| 在线欧美一区二区| 99精品视频一区| 99久精品国产| 99re在线精品| 色香色香欲天天天影视综合网| 91色porny蝌蚪| 色激情天天射综合网| 日本韩国一区二区三区视频| 色综合久久六月婷婷中文字幕| 91在线无精精品入口| 91色在线porny| 91福利小视频| 欧美精品日韩精品| 日韩免费视频一区二区| 亚洲精品一区二区三区精华液| 精品国产一区二区亚洲人成毛片| 精品国产乱码久久久久久牛牛| 日韩美女一区二区三区四区| 26uuu亚洲综合色欧美| 久久九九99视频| 亚洲欧美日韩国产手机在线| 亚洲综合在线观看视频| 午夜国产不卡在线观看视频| 麻豆精品新av中文字幕| 亚洲精品亚洲人成人网| 亚洲一线二线三线视频| 日产欧产美韩系列久久99| 久久66热偷产精品| 波多野结衣亚洲| 欧美年轻男男videosbes| 欧美日韩精品福利| 久久亚洲私人国产精品va媚药| 国产欧美日韩在线| 亚洲男人的天堂在线aⅴ视频| 日本在线不卡一区| 国产成人av电影在线| 欧美性大战久久| 久久久九九九九| 亚洲一区二区三区四区在线观看 | 国产一区二区三区免费播放| 成人av影视在线观看| 欧美日韩国产精品自在自线| 久久精品免视看| 亚洲午夜激情网站| 国产一区二区三区美女| 欧美影院午夜播放| 久久精品一区八戒影视| 亚洲已满18点击进入久久| 国产精品99久| 91麻豆精品国产自产在线| 国产精品欧美久久久久无广告 | 91浏览器打开|