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

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

?? remove.c

?? linux開發技術詳解一書的源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* remove.c -- core functions for removing files and directories
   Copyright (C) 88, 90, 91, 1994-2002 Free Software Foundation, Inc.

   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.  */

/* Extracted from rm.c and librarified, then rewritten by Jim Meyering.  */

#ifdef _AIX
 #pragma alloca
#endif

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

#include "save-cwd.h"
#include "system.h"
#include "dirname.h"
#include "error.h"
#include "file-type.h"
#include "hash.h"
#include "hash-pjw.h"
#include "obstack.h"
#include "quote.h"
#include "remove.h"

/* Avoid shadowing warnings because these are functions declared
   in dirname.h as well as locals used below.  */
#define dir_name rm_dir_name
#define dir_len rm_dir_len

#define obstack_chunk_alloc malloc
#define obstack_chunk_free free

#ifndef PARAMS
# if defined (__GNUC__) || __STDC__
#  define PARAMS(args) args
# else
#  define PARAMS(args) ()
# endif
#endif

/* FIXME: if possible, use autoconf...  */
#ifdef __GLIBC__
# define ROOT_CAN_UNLINK_DIRS 0
#else
# define ROOT_CAN_UNLINK_DIRS 1
#endif

enum Ternary
  {
    T_UNKNOWN = 2,
    T_NO,
    T_YES
  };
typedef enum Ternary Ternary;

/* The prompt function may be called twice a given directory.
   The first time, we ask whether to descend into it, and the
   second time, we ask whether to remove it.  */
enum Prompt_action
  {
    PA_DESCEND_INTO_DIR = 2,
    PA_REMOVE_DIR
  };

/* On systems with an lstat function that accepts the empty string,
   arrange to make lstat calls go through the wrapper function.  */
#if HAVE_LSTAT_EMPTY_STRING_BUG
int rpl_lstat PARAMS((const char *, struct stat *));
# define lstat(Name, Stat_buf) rpl_lstat(Name, Stat_buf)
#endif

#ifdef D_INO_IN_DIRENT
# define D_INO(dp) ((dp)->d_ino)
# define ENABLE_CYCLE_CHECK
#else
/* Some systems don't have inodes, so fake them to avoid lots of ifdefs.  */
# define D_INO(dp) 1
#endif

#if !defined S_ISLNK
# define S_ISLNK(Mode) 0
#endif

/* Initial capacity of per-directory hash table of entries that have
   been processed but not been deleted.  */
#define HT_UNREMOVABLE_INITIAL_CAPACITY 13

/* An entry in the active directory stack.
   Each entry corresponds to an `active' directory.  */
struct AD_ent
{
  /* For a given active directory, this is the set of names of
     entries in that directory that could/should not be removed.
     For example, `.' and `..', as well as files/dirs for which
     unlink/rmdir failed e.g., due to access restrictions.  */
  Hash_table *unremovable;

  /* Record the status for a given active directory; we need to know
     whether an entry was not removed, either because of an error or
     because the user declined.  */
  enum RM_status status;

  union
  {
    /* The directory's dev/ino.  Used to ensure that `chdir some-subdir', then
       `chdir ..' takes us back to the same directory from which we started).
       (valid for all but the bottommost entry on the stack.  */
    struct dev_ino a;

    /* Enough information to restore the initial working directory.
       (valid only for the bottommost entry on the stack)  */
    struct saved_cwd saved_cwd;
  } u;
};

int euidaccess ();
int yesno ();

extern char *program_name;

/* The name of the directory (starting with and relative to a command
   line argument) being processed.  When a subdirectory is entered, a new
   component is appended (pushed).  When RM chdir's out of a directory,
   the top component is removed (popped).  This is used to form a full
   file name when necessary.  */
static struct obstack dir_stack;

/* Stack of lengths of directory names (including trailing slash)
   appended to dir_stack.  We have to have a separate stack of lengths
   (rather than just popping back to previous slash) because the first
   element pushed onto the dir stack may contain slashes.  */
static struct obstack len_stack;

/* Stack of active directory entries.
   The first `active' directory is the initial working directory.
   Additional active dirs are pushed onto the stack as rm `chdir's
   into each nonempty directory it must remove.  When rm has finished
   removing the hierarchy under a directory, it pops the active dir stack.  */
static struct obstack Active_dir;

static void
hash_freer (void *x)
{
  free (x);
}

static bool
hash_compare_strings (void const *x, void const *y)
{
  return STREQ (x, y) ? true : false;
}

static inline void
push_dir (const char *dir_name)
{
  size_t len;

  len = strlen (dir_name);

  /* Append the string onto the stack.  */
  obstack_grow (&dir_stack, dir_name, len);

  /* Append a trailing slash.  */
  obstack_1grow (&dir_stack, '/');

  /* Add one for the slash.  */
  ++len;

  /* Push the length (including slash) onto its stack.  */
  obstack_grow (&len_stack, &len, sizeof (len));
}

/* Return the entry name of the directory on the top of the stack
   in malloc'd storage.  */
static inline char *
top_dir (void)
{
  int n_lengths = obstack_object_size (&len_stack) / sizeof (size_t);
  size_t *length = (size_t *) obstack_base (&len_stack);
  size_t top_len = length[n_lengths - 1];
  char const *p = obstack_next_free (&dir_stack) - top_len;
  char *q = xmalloc (top_len);
  memcpy (q, p, top_len - 1);
  q[top_len - 1] = 0;
  return q;
}

static inline void
pop_dir (void)
{
  int n_lengths = obstack_object_size (&len_stack) / sizeof (size_t);
  size_t *length = (size_t *) obstack_base (&len_stack);
  size_t top_len;

  assert (n_lengths > 0);
  top_len = length[n_lengths - 1];
  assert (top_len >= 2);

  /* Pop off the specified length of pathname.  */
  assert (obstack_object_size (&dir_stack) >= top_len);
  obstack_blank (&dir_stack, -top_len);

  /* Pop the length stack, too.  */
  assert (obstack_object_size (&len_stack) >= sizeof (size_t));
  obstack_blank (&len_stack, (int) -(sizeof (size_t)));
}

/* Copy the SRC_LEN bytes of data beginning at SRC into the DST_LEN-byte
   buffer, DST, so that the last source byte is at the end of the destination
   buffer.  If SRC_LEN is longer than DST_LEN, then set *TRUNCATED to non-zero.
   Set *RESULT to point to the beginning of (the portion of) the source data
   in DST.  Return the number of bytes remaining in the destination buffer.  */

static size_t
right_justify (char *dst, size_t dst_len, const char *src, size_t src_len,
	       char **result, int *truncated)
{
  const char *sp;
  char *dp;

  if (src_len <= dst_len)
    {
      sp = src;
      dp = dst + (dst_len - src_len);
      *truncated = 0;
    }
  else
    {
      sp = src + (src_len - dst_len);
      dp = dst;
      src_len = dst_len;
      *truncated = 1;
    }

  *result = memcpy (dp, sp, src_len);
  return dst_len - src_len;
}

/* Using the global directory name obstack, create the full path to FILENAME.
   Return it in sometimes-realloc'd space that should not be freed by the
   caller.  Realloc as necessary.  If realloc fails, use a static buffer
   and put as long a suffix in that buffer as possible.  */

static char *
full_filename (const char *filename)
{
  static char *buf = NULL;
  static size_t n_allocated = 0;

  int dir_len = obstack_object_size (&dir_stack);
  char *dir_name = (char *) obstack_base (&dir_stack);
  size_t n_bytes_needed;
  size_t filename_len;

  filename_len = strlen (filename);
  n_bytes_needed = dir_len + filename_len + 1;

  if (n_bytes_needed > n_allocated)
    {
      /* This code requires that realloc accept NULL as the first arg.
         This function must not use xrealloc.  Otherwise, an out-of-memory
	 error involving a file name to be expanded here wouldn't ever
	 be issued.  Use realloc and fall back on using a static buffer
	 if memory allocation fails.  */
      buf = realloc (buf, n_bytes_needed);
      n_allocated = n_bytes_needed;

      if (buf == NULL)
	{
#define SBUF_SIZE 512
#define ELLIPSES_PREFIX "[...]"
	  static char static_buf[SBUF_SIZE];
	  int truncated;
	  size_t len;
	  char *p;

	  len = right_justify (static_buf, SBUF_SIZE, filename,
			       filename_len + 1, &p, &truncated);
	  right_justify (static_buf, len, dir_name, dir_len, &p, &truncated);
	  if (truncated)
	    {
	      memcpy (static_buf, ELLIPSES_PREFIX,
		      sizeof (ELLIPSES_PREFIX) - 1);
	    }
	  return p;
	}
    }

  /* Copy directory part, including trailing slash, and then
     append the filename part, including a trailing zero byte.  */
  memcpy (mempcpy (buf, dir_name, dir_len), filename, filename_len + 1);

  assert (strlen (buf) + 1 == n_bytes_needed);

  return buf;
}

static size_t
AD_stack_height (void)
{
  return obstack_object_size (&Active_dir) / sizeof (struct AD_ent);
}

static struct AD_ent *
AD_stack_top (void)
{
  return (struct AD_ent *)
    ((char *) obstack_next_free (&Active_dir) - sizeof (struct AD_ent));
}

static void
AD_stack_pop (void)
{
  /* operate on Active_dir.  pop and free top entry */
  struct AD_ent *top = AD_stack_top ();
  if (top->unremovable)
    hash_free (top->unremovable);
  obstack_blank (&Active_dir, -sizeof (struct AD_ent));
  pop_dir ();
}

/* chdir `up' one level.
   Whenever using chdir '..', verify that the post-chdir
   dev/ino numbers for `.' match the saved ones.
   Return the name (in malloc'd storage) of the
   directory (usually now empty) from which we're coming.  */
static char *
AD_pop_and_chdir (void)
{
  /* Get the name of the current directory from the top of the stack.  */
  char *dir = top_dir ();
  enum RM_status old_status = AD_stack_top()->status;
  struct stat sb;
  struct AD_ent *top;

  AD_stack_pop ();

  /* Propagate any failure to parent.  */
  UPDATE_STATUS (AD_stack_top()->status, old_status);

  assert (AD_stack_height ());

  top = AD_stack_top ();
  if (1 < AD_stack_height ())
    {
      /* We can give a better diagnostic here, since the target is relative. */
      if (chdir (".."))
	{
	  error (EXIT_FAILURE, errno,
		 _("cannot chdir from %s to .."),
		 quote (full_filename (".")));
	}
    }
  else
    {
      if (restore_cwd (&top->u.saved_cwd, NULL, NULL))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产 欧美在线| 色综合久久六月婷婷中文字幕| 国产精品女主播av| 欧美日韩精品一区二区| 成人国产精品免费网站| 日韩av电影免费观看高清完整版在线观看| 日本一区二区免费在线观看视频 | 一区二区三区美女视频| 日韩精品一区二区三区在线 | 免费亚洲电影在线| 中文字幕一区二区三区四区| 精品国产免费人成电影在线观看四季| 91精彩视频在线| 成人sese在线| 国产成人8x视频一区二区| 蜜臀a∨国产成人精品| 亚洲小少妇裸体bbw| 亚洲欧美日韩国产手机在线| 麻豆精品在线播放| 亚洲国产精品麻豆| 亚洲蜜臀av乱码久久精品蜜桃| 久久久久久久久久久久电影| 欧美一二三四在线| 欧美一区二区啪啪| 欧美福利视频一区| 欧美日韩一区二区三区免费看| 91在线码无精品| eeuss鲁片一区二区三区在线看 | 欧美日韩一区二区三区不卡| 91在线观看污| www.99精品| 99久久久久久| 一本到一区二区三区| 99在线精品一区二区三区| 国产v综合v亚洲欧| 高清在线成人网| 成人小视频在线观看| 国产91精品精华液一区二区三区| 国产伦精一区二区三区| 国产一区在线精品| 国产成人在线视频免费播放| 国产一区二区三区国产| 国产福利一区二区三区在线视频| 国产精品综合一区二区| 国产成人精品亚洲午夜麻豆| 国产在线精品一区二区三区不卡| 精品亚洲porn| 国产91高潮流白浆在线麻豆| 成人综合在线观看| 97久久精品人人澡人人爽| 色网站国产精品| 欧美三级蜜桃2在线观看| 欧美日韩国产一级| 精品免费视频一区二区| 久久麻豆一区二区| 国产偷国产偷精品高清尤物| 中文字幕亚洲电影| 亚洲成人自拍偷拍| 寂寞少妇一区二区三区| 成人性生交大合| 欧美主播一区二区三区| 日韩一区二区三区在线观看| 久久理论电影网| 亚洲欧美自拍偷拍色图| 亚洲午夜电影在线| 久久精品99久久久| va亚洲va日韩不卡在线观看| 欧美亚洲日本国产| 欧美zozo另类异族| 亚洲欧美偷拍另类a∨色屁股| 亚洲电影一区二区| 国产精品一区二区三区网站| 91丨porny丨国产| 日韩一区国产二区欧美三区| 中文av一区特黄| 亚洲va中文字幕| 国产精品一级黄| 色哟哟国产精品| 精品国产乱码久久久久久久| 18欧美亚洲精品| 毛片av一区二区三区| 波多野结衣欧美| 91麻豆精品国产91久久久久久| 国产午夜精品福利| 亚洲国产精品影院| 成人免费视频一区| 91麻豆精品国产无毒不卡在线观看 | 欧美tickling挠脚心丨vk| 亚洲特级片在线| 国产一区二区三区四区在线观看| 日本久久一区二区| 国产校园另类小说区| 亚洲大片一区二区三区| 成人免费av资源| 欧美电视剧在线观看完整版| 一区二区成人在线| 成人性视频免费网站| 日韩欧美视频一区| 亚洲男帅同性gay1069| 国产在线国偷精品免费看| 欧美性做爰猛烈叫床潮| 国产精品久久久一区麻豆最新章节| 污片在线观看一区二区| av资源站一区| 欧美激情一区二区三区不卡| 美日韩一区二区三区| 欧美影视一区在线| 亚洲色图在线播放| 国产v日产∨综合v精品视频| 欧美videofree性高清杂交| 五月激情六月综合| 在线亚洲+欧美+日本专区| 国产精品视频麻豆| 国产激情视频一区二区在线观看| 欧美一区二区三区免费大片| 亚洲国产欧美日韩另类综合| 色综合久久综合中文综合网| 国产精品欧美综合在线| 国产福利一区二区三区| 久久青草欧美一区二区三区| 久久国产生活片100| 欧美一区二区三区色| 日韩成人精品在线| 欧美一区二区视频观看视频| 亚洲mv在线观看| 欧美日本精品一区二区三区| 一区二区三区中文字幕精品精品| 91在线观看地址| 国产精品福利影院| 波多野结衣中文一区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 日本精品一区二区三区高清 | 国产精品三级av| 成人在线视频一区二区| 国产精品麻豆99久久久久久| 国产成人亚洲精品青草天美| 国产三级精品视频| 大胆亚洲人体视频| 日韩伦理av电影| 色哟哟一区二区| 亚洲高清久久久| 这里只有精品99re| 韩国在线一区二区| 欧美国产综合色视频| 99精品久久免费看蜜臀剧情介绍| 亚洲图片欧美激情| 91黄色在线观看| 亚洲18女电影在线观看| 日韩欧美国产不卡| 国产成人免费视频一区| 1000部国产精品成人观看| 91黄色免费观看| 天天色天天操综合| 欧美精品一区二区三区高清aⅴ| 国产精品99久久久| 综合久久综合久久| 欧美日本一区二区| 韩国av一区二区| 亚洲丝袜另类动漫二区| 欧美日韩一卡二卡三卡 | 2021久久国产精品不只是精品| 国产成人一级电影| 亚洲柠檬福利资源导航| 欧美一区二区三区啪啪| 国产91丝袜在线播放| 亚洲综合成人网| 欧美精品一区二区三区很污很色的| 成人丝袜18视频在线观看| 亚洲妇熟xx妇色黄| 欧美国产精品中文字幕| 欧美色综合影院| 国产裸体歌舞团一区二区| 亚洲美女屁股眼交3| 精品日韩在线一区| 91碰在线视频| 久久国产精品第一页| 亚洲同性同志一二三专区| 欧美伦理电影网| 成人动漫一区二区在线| 日韩电影一二三区| 国产精品嫩草久久久久| 7777精品伊人久久久大香线蕉完整版| 国产suv精品一区二区883| 亚洲国产精品自拍| 国产精品久久免费看| 欧美一级国产精品| 91成人国产精品| 国产精品77777| 天堂午夜影视日韩欧美一区二区| 国产欧美日韩在线| 欧美一级淫片007| 91女神在线视频| 国产在线精品国自产拍免费| 亚洲国产一区二区视频| 国产精品网站在线播放| 精品国产一区a| 欧美肥妇bbw| 91成人网在线| 91蝌蚪porny九色| 国产精品自在在线|