Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/libbb/recursive_action.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 48  static int FAST_FUNC true_action(const c Line 48  static int FAST_FUNC true_action(const c
48   * into that directory, instead recursive_action() returns 0 (if FALSE)   * into that directory, instead recursive_action() returns 0 (if FALSE)
49   * or 1 (if SKIP)   * or 1 (if SKIP)
50   *   *
51   * followLinks=0/1 differs mainly in handling of links to dirs.   * ACTION_FOLLOWLINKS mainly controls handling of links to dirs.
52   * 0: lstat(statbuf). Calls fileAction on link name even if points to dir.   * 0: lstat(statbuf). Calls fileAction on link name even if points to dir.
53   * 1: stat(statbuf). Calls dirAction and optionally recurse on link to dir.   * 1: stat(statbuf). Calls dirAction and optionally recurse on link to dir.
54   */   */
# Line 61  int FAST_FUNC recursive_action(const cha Line 61  int FAST_FUNC recursive_action(const cha
61   unsigned depth)   unsigned depth)
62  {  {
63   struct stat statbuf;   struct stat statbuf;
64     unsigned follow;
65   int status;   int status;
66   DIR *dir;   DIR *dir;
67   struct dirent *next;   struct dirent *next;
# Line 68  int FAST_FUNC recursive_action(const cha Line 69  int FAST_FUNC recursive_action(const cha
69   if (!fileAction) fileAction = true_action;   if (!fileAction) fileAction = true_action;
70   if (!dirAction) dirAction = true_action;   if (!dirAction) dirAction = true_action;
71    
72   status = ACTION_FOLLOWLINKS; /* hijack a variable for bitmask... */   follow = ACTION_FOLLOWLINKS;
73   if (!depth)   if (depth == 0)
74   status = ACTION_FOLLOWLINKS | ACTION_FOLLOWLINKS_L0;   follow = ACTION_FOLLOWLINKS | ACTION_FOLLOWLINKS_L0;
75   status = ((flags & status) ? stat : lstat)(fileName, &statbuf);   follow &= flags;
76     status = (follow ? stat : lstat)(fileName, &statbuf);
77   if (status < 0) {   if (status < 0) {
78  #ifdef DEBUG_RECURS_ACTION  #ifdef DEBUG_RECURS_ACTION
79   bb_error_msg("status=%d flags=%x", status, flags);   bb_error_msg("status=%d flags=%x", status, flags);
80  #endif  #endif
81     if ((flags & ACTION_DANGLING_OK)
82     && errno == ENOENT
83     && lstat(fileName, &statbuf) == 0
84     ) {
85     /* Dangling link */
86     return fileAction(fileName, &statbuf, userData, depth);
87     }
88   goto done_nak_warn;   goto done_nak_warn;
89   }   }
90    

Legend:
Removed from v.983  
changed lines
  Added in v.984