Changeset 167 for trunk/src/sh_unix.c
- Timestamp:
- Mar 15, 2008, 12:38:20 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_unix.c
r162 r167 3062 3062 3063 3063 /* return */ 3064 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 3064 3065 SL_RETURN( 0, _("sh_unix_checksum_size")); 3065 3066 } 3066 3067 3067 3068 out: 3069 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 3068 3070 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); 3069 3071 SL_RETURN( -1, _("sh_unix_checksum_size")); … … 3279 3281 int fd; 3280 3282 int fstat_return; 3281 3283 sh_string * content = NULL; 3284 3282 3285 time_t tend; 3283 3286 time_t tstart; … … 3302 3305 fstat_return = -1; 3303 3306 rval_open = -1; 3307 3308 theFile->link_path = NULL; 3304 3309 3305 3310 if (stat_return == 0 && S_ISREG(buf.st_mode)) … … 3396 3401 char hashbuf[KEYBUF_SIZE]; 3397 3402 UINT64 length_nolim = TIGER_NOLIM; 3403 3404 if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < SH_TXT_MAX) 3405 { 3406 sl_init_content (rval_open, fbuf.st_size); 3407 } 3408 3398 3409 sl_strlcpy(fileHash, 3399 3410 sh_tiger_generic_hash (theFile->fullpath, … … 3402 3413 hashbuf, sizeof(hashbuf)), 3403 3414 KEY_LEN+1); 3415 3416 content = sl_get_content(rval_open); 3417 3404 3418 if ((theFile->check_mask & MODI_SGROW) != 0) 3405 3419 { … … 3439 3453 char hashbuf[KEYBUF_SIZE]; 3440 3454 UINT64 length_nolim = TIGER_NOLIM; 3455 3456 if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < SH_TXT_MAX) 3457 { 3458 sl_init_content (rval_open, fbuf.st_size); 3459 } 3460 3441 3461 sl_strlcpy(fileHash, 3442 3462 sh_tiger_generic_hash (theFile->fullpath, rval_open, … … 3445 3465 hashbuf, sizeof(hashbuf)), 3446 3466 KEY_LEN + 1); 3467 3468 content = sl_get_content(rval_open); 3469 3447 3470 if ((theFile->check_mask & MODI_SGROW) != 0) 3448 3471 { … … 3617 3640 if (theFile->c_mode[0] == 'l') 3618 3641 { 3619 3620 3642 linknamebuf = SH_ALLOC(PATH_MAX); 3621 3643 … … 3637 3659 SH_FREE(tmp2); 3638 3660 SH_FREE(linknamebuf); 3639 theFile->linkpath[0] = '-'; 3640 theFile->linkpath[1] = '\0'; 3661 theFile->link_path = sh_util_strdup("-"); 3641 3662 SL_RETURN((-1),_("sh_unix_getinfo")); 3642 3663 } 3643 3664 3644 if (linknamebuf[0] == '/') 3645 { 3646 sl_strlcpy (theFile->linkpath, linknamebuf, PATH_MAX); 3647 } 3648 else 3649 { 3650 tmp = sh_util_dirname(theFile->fullpath); 3651 if (tmp) { 3652 sl_strlcpy (theFile->linkpath, tmp, PATH_MAX); 3665 if (linknamebuf[0] == '/') 3666 { 3667 theFile->link_path = sh_util_strdup (linknamebuf); 3668 } 3669 else 3670 { 3671 tmp = sh_util_dirname(theFile->fullpath); 3672 if (tmp) { 3673 theFile->link_path = SH_ALLOC(PATH_MAX); 3674 sl_strlcpy (theFile->link_path, tmp, PATH_MAX); 3675 SH_FREE(tmp); 3676 } else { 3677 theFile->link_path = SH_ALLOC(PATH_MAX); 3678 theFile->link_path[0] = '\0'; 3679 } 3680 /* 3681 * Only attach '/' if not root directory. Handle "//", which 3682 * according to POSIX is implementation-defined, and may be 3683 * different from "/" (however, three or more '/' will collapse 3684 * to one). 3685 */ 3686 tmp = theFile->link_path; while (*tmp == '/') ++tmp; 3687 if (*tmp != '\0') 3688 { 3689 sl_strlcat (theFile->link_path, "/", PATH_MAX); 3690 } 3691 sl_strlcat (theFile->link_path, linknamebuf, PATH_MAX); 3692 } 3693 3694 /* stat the link 3695 */ 3696 stat_return = retry_lstat (FIL__, __LINE__, theFile->link_path, &lbuf); 3697 3698 /* check for error 3699 */ 3700 if (stat_return != 0) 3701 { 3702 stat_return = errno; 3703 tmp = sh_util_safe_name (theFile->fullpath); 3704 tmp2 = sh_util_safe_name (theFile->link_path); 3705 if (stat_return != ENOENT) 3706 { 3707 char errbuf[SH_ERRBUF_SIZE]; 3708 sh_error_handle (level, FIL__, __LINE__, stat_return, 3709 MSG_FI_LSTAT, 3710 sh_error_message (stat_return,errbuf, sizeof(errbuf)), 3711 tmp2); 3712 } 3713 else 3714 { 3715 /* a dangling link -- everybody seems to have plenty of them 3716 */ 3717 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_DLNK, 3718 tmp, tmp2); 3719 } 3720 theFile->linkisok = BAD; 3653 3721 SH_FREE(tmp); 3654 } else { 3655 theFile->linkpath[0] = '\0'; 3656 } 3657 /* 3658 * Only attach '/' if not root directory. Handle "//", which 3659 * according to POSIX is implementation-defined, and may be 3660 * different from "/" (however, three or more '/' will collapse 3661 * to one). 3662 */ 3663 tmp = theFile->linkpath; while (*tmp == '/') ++tmp; 3664 if (*tmp != '\0') 3665 { 3666 sl_strlcat (theFile->linkpath, "/", PATH_MAX); 3667 } 3668 sl_strlcat (theFile->linkpath, linknamebuf, PATH_MAX); 3669 } 3670 3671 /* stat the link 3672 */ 3673 stat_return = retry_lstat (FIL__, __LINE__, theFile->linkpath, &lbuf); 3674 3675 /* check for error 3676 */ 3677 if (stat_return != 0) 3678 { 3679 stat_return = errno; 3680 tmp = sh_util_safe_name (theFile->fullpath); 3681 tmp2 = sh_util_safe_name (theFile->linkpath); 3682 if (stat_return != ENOENT) 3683 { 3684 char errbuf[SH_ERRBUF_SIZE]; 3685 sh_error_handle (level, FIL__, __LINE__, stat_return, 3686 MSG_FI_LSTAT, 3687 sh_error_message (stat_return,errbuf, sizeof(errbuf)), 3688 tmp2); 3689 } 3690 else 3691 { 3692 /* a dangling link -- everybody seems to have plenty of them 3693 */ 3694 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_DLNK, 3695 tmp, tmp2); 3696 } 3697 theFile->linkisok = BAD; 3698 SH_FREE(tmp); 3699 SH_FREE(tmp2); 3700 SH_FREE(linknamebuf); 3701 /* 3702 * changed Tue Feb 10 16:16:13 CET 2004: 3703 * add dangling symlinks into database 3704 * SL_RETURN((-1),_("sh_unix_getinfo")); 3705 */ 3706 theFile->linkmode = 0; 3707 SL_RETURN((0),_("sh_unix_getinfo")); 3708 } 3709 3710 theFile->linkisok = GOOD; 3722 SH_FREE(tmp2); 3723 SH_FREE(linknamebuf); 3724 /* 3725 * changed Tue Feb 10 16:16:13 CET 2004: 3726 * add dangling symlinks into database 3727 * SL_RETURN((-1),_("sh_unix_getinfo")); 3728 */ 3729 theFile->linkmode = 0; 3730 SL_RETURN((0),_("sh_unix_getinfo")); 3731 } 3711 3732 3712 3713 /* --- Determine file type. --- 3714 */ 3715 sh_unix_getinfo_type (&lbuf, &type, theFile->link_c_mode); 3716 theFile->type = type; 3717 3718 /* --- Determine permissions. --- 3719 */ 3720 sh_unix_getinfo_mode (&lbuf, &mode, theFile->link_c_mode); 3721 theFile->linkmode = lbuf.st_mode; 3722 3723 /* --- Output the link. --- 3724 */ 3725 if (theFile->linkisok == GOOD) 3726 { 3727 tmp2 = sh_util_safe_name (linknamebuf); 3728 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_LLNK, 3729 theFile->link_c_mode, tmp2); 3730 SH_FREE(tmp2); 3731 } 3732 SH_FREE(linknamebuf); 3733 } 3733 theFile->linkisok = GOOD; 3734 3735 3736 /* --- Determine file type. --- 3737 */ 3738 sh_unix_getinfo_type (&lbuf, &type, theFile->link_c_mode); 3739 theFile->type = type; 3740 3741 /* --- Determine permissions. --- 3742 */ 3743 sh_unix_getinfo_mode (&lbuf, &mode, theFile->link_c_mode); 3744 theFile->linkmode = lbuf.st_mode; 3745 3746 /* --- Output the link. --- 3747 */ 3748 if (theFile->linkisok == GOOD) 3749 { 3750 tmp2 = sh_util_safe_name (linknamebuf); 3751 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_LLNK, 3752 theFile->link_c_mode, tmp2); 3753 SH_FREE(tmp2); 3754 } 3755 SH_FREE(linknamebuf); 3756 } 3757 else /* not a link */ 3758 { 3759 if (content) 3760 { 3761 sh_util_base64_enc_alloc (&(theFile->link_path), 3762 sh_string_str(content), 3763 sh_string_len(content)); 3764 } 3765 } 3734 3766 SL_RETURN((0),_("sh_unix_getinfo")); 3735 3767 }
Note:
See TracChangeset
for help on using the changeset viewer.