Changeset 10 for trunk/src/sh_unix.c


Ignore:
Timestamp:
Jan 1, 2006, 11:58:26 PM (19 years ago)
Author:
rainer
Message:

Support *BSD file flags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_unix.c

    r8 r10  
    23632363 **************************************************************/
    23642364
    2365 #if defined(__linux__)
    2366 
    2367 #if defined(HAVE_LINUX_EXT2_FS_H) || defined(HAVE_EXT2FS_EXT2_FS_H)
     2365#if (defined(__linux__) && (defined(HAVE_LINUX_EXT2_FS_H) || defined(HAVE_EXT2FS_EXT2_FS_H))) || defined(HAVE_STAT_FLAGS)
     2366
     2367#if defined(__linux__)
    23682368
    23692369/* --- Determine ext2fs file attributes. ---
     
    23762376#endif
    23772377
     2378/* __linux__ includes */
     2379#endif
     2380
    23782381static
    23792382int sh_unix_getinfo_attr (char * name,
    23802383                          unsigned long * flags,
    23812384                          char * c_attr,
    2382                           int fd)
     2385                          int fd, struct stat * buf)
    23832386{
    23842387
     
    23962399
    23972400#ifdef HAVE_STAT_FLAGS
    2398   struct stat buf;
    2399   int    i;
    24002401
    24012402  SL_ENTER(_("sh_unix_getinfo_attr"));
     
    24032404  *flags = 0;
    24042405
    2405   i = retry_stat (FIL__, __LINE__, name, &buf);
    2406 
    2407   if (i == -1)
    2408     SL_RETURN(-1, _("sh_unix_getinfo_attr"));
    2409 
     2406  /* cast to void to avoid compiler warning about unused parameters */
     2407  (void) fd;
     2408  (void) name;
     2409
     2410#ifdef UF_NODUMP
     2411  if (buf->st_flags & UF_NODUMP) {
     2412    *flags |= UF_NODUMP;
     2413    c_attr[0] = 'd';
     2414  }
     2415#endif
    24102416#ifdef UF_IMMUTABLE
    2411   if (buf.st_flags & UF_IMMUTABLE)
    2412     *flags |= EXT2_IMMUTABLE_FL;
     2417  if (buf->st_flags & UF_IMMUTABLE) {
     2418    *flags |= UF_IMMUTABLE;
     2419    c_attr[1] = 'i';
     2420  }
    24132421#endif
    24142422#ifdef UF_APPEND
    2415   if (buf.st_flags & UF_APPEND)
    2416     *flags |= EXT2_APPEND_FL;
    2417 #endif
    2418 #ifdef UF_NODUMP
    2419   if (buf.st_flags & UF_NODUMP)
    2420     *flags |= EXT2_NODUMP_FL;
    2421 #endif
    2422 
     2423  if (buf->st_flags & UF_APPEND) {
     2424    *flags |= UF_APPEND;
     2425    c_attr[2] = 'a';
     2426  }
     2427#endif
     2428#ifdef UF_NOUNLINK
     2429  if (buf->st_flags & UF_NOUNLINK) {
     2430    *flags |= UF_NOUNLINK;
     2431    c_attr[3] = 'u';
     2432  }
     2433#endif
     2434#ifdef UF_OPAQUE
     2435  if (buf->st_flags & UF_OPAQUE) {
     2436    *flags |= UF_OPAQUE;
     2437    c_attr[4] = 'o';
     2438  }
     2439#endif
     2440#ifdef SF_ARCHIVED
     2441  if (buf->st_flags & SF_ARCHIVED) {
     2442    *flags |= SF_ARCHIVED;
     2443    c_attr[5] = 'R';
     2444  }
     2445   
     2446#endif
     2447#ifdef SF_IMMUTABLE
     2448  if (buf->st_flags & SF_IMMUTABLE) {
     2449    *flags |= SF_IMMUTABLE;
     2450    c_attr[6] = 'I';
     2451  }
     2452#endif
     2453#ifdef SF_APPEND
     2454  if (buf->st_flags & SF_APPEND) {
     2455    *flags |= SF_APPEND;
     2456    c_attr[7] = 'A';
     2457  }
     2458#endif
     2459#ifdef SF_NOUNLINK
     2460  if (buf->st_flags & SF_NOUNLINK) {
     2461    *flags |= SF_NOUNLINK;
     2462    c_attr[8] = 'U';
     2463  }
     2464#endif
     2465
     2466  /* ! HAVE_STAT_FLAGS */
    24232467#else
    24242468
     
    24292473
    24302474  *flags = 0;
     2475  (void) buf;
    24312476
    24322477  /* open() -> aud_open() R.Wichmann
     
    24442489    SL_RETURN(-1, _("sh_unix_getinfo_attr"));
    24452490
     2491  if (f == 0)
     2492    SL_RETURN(0, _("sh_unix_getinfo_attr"));
     2493
    24462494  *flags = f;
    24472495
     
    24552503/* ! HAVE_EXT2_IOCTLS */
    24562504#endif
    2457 #endif
    24582505/*
    24592506 * END
     
    24622509 */
    24632510
     2511  if (*flags == 0)
     2512    goto theend;
     2513
    24642514#ifdef EXT2_SECRM_FL
    24652515  if ( (*flags & EXT2_SECRM_FL) != 0  )   c_attr[0] = 's';
     
    24862536  if ( (*flags & EXT2_COMPR_FL) != 0   )  c_attr[7] = 'c';
    24872537#endif
    2488 #ifdef EXT2_COMPRBLK_FL
    2489   if ( (*flags & EXT2_COMPRBLK_FL) != 0)  c_attr[8] = 'B';
    2490 #endif
    2491 #ifdef EXT2_DIRTY_FL
    2492   if ( (*flags & EXT2_DIRTY_FL) != 0   )  c_attr[9] = 'D';
    2493 #endif
    2494 #ifdef EXT2_NOCOMPR_FL
    2495   if ( (*flags & EXT2_NOCOMPR_FL) != 0 )  c_attr[10] = 'D';
    2496 #endif
    2497 #ifdef EXT2_ECOMPR_FL
    2498   if ( (*flags & EXT2_ECOMPR_FL) != 0  )  c_attr[11] = 'D';
     2538
     2539#ifdef EXT2_TOPDIR_FL
     2540  if ( (*flags & EXT2_TOPDIR_FL) != 0  )  c_attr[8] = 'T';
     2541#endif
     2542#ifdef EXT2_DIRSYNC_FL
     2543  if ( (*flags & EXT2_DIRSYNC_FL) != 0 )  c_attr[9] = 'D';
     2544#endif
     2545#ifdef EXT2_NOTAIL_FL
     2546  if ( (*flags & EXT2_NOTAIL_FL) != 0  )  c_attr[10] = 't';
     2547#endif
     2548#ifdef EXT2_JOURNAL_DATA_FL
     2549  if ( (*flags & EXT2_JOURNAL_DATA_FL) != 0)  c_attr[11] = 'j';
     2550#endif
     2551
     2552 theend:
     2553  /* ext2 */
    24992554#endif
    25002555
     
    25082563                          unsigned long * flags,
    25092564                          char * c_attr,
    2510                           int fd)
     2565                          int fd, struct stat * buf)
    25112566{
    25122567  return 0;
    25132568}
    2514 #endif
    2515 
    2516 /* __LINUX__ */
     2569
     2570/* defined(__linux__) || defined(HAVE_STAT_FLAGS) */
    25172571#endif
    25182572
     
    29082962  theFile->type = type;
    29092963
    2910 #if defined(__linux__)
     2964#if defined(__linux__) || defined(HAVE_STAT_FLAGS)
    29112965
    29122966  /* --- Determine file attributes. ---
     
    29192973      theFile->c_mode[0] != 'l' )
    29202974    sh_unix_getinfo_attr(theFile->fullpath,
    2921                          &theFile->attributes, theFile->c_attributes, fd);
    2922 
     2975                         &theFile->attributes, theFile->c_attributes,
     2976                         fd, &buf);
    29232977#endif
    29242978
Note: See TracChangeset for help on using the changeset viewer.