Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_fs_fs/fs_fs.c view on Meta::CPAN
/* Look for the next previous newline. */
for (i = num_bytes - 2; i >= 0; i--)
{
if (buf[i] == '\n')
break;
}
if (i < 0)
{
return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
_("Final line in revision file (r%ld) longer "
"than 64 characters"),
rev);
}
i++;
str = &buf[i];
/* find the next space */
for ( ; i < (num_bytes - 2) ; i++)
if (buf[i] == ' ')
break;
if (i == (num_bytes - 2))
return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
_("Final line in revision file r%ld missing space"),
rev);
if (root_offset)
{
apr_int64_t val;
buf[i] = '\0';
SVN_ERR(svn_cstring_atoi64(&val, str));
*root_offset = rev_offset + (apr_off_t)val;
}
i++;
str = &buf[i];
/* find the next newline */
for ( ; i < num_bytes; i++)
if (buf[i] == '\n')
break;
if (changes_offset)
{
apr_int64_t val;
buf[i] = '\0';
SVN_ERR(svn_cstring_atoi64(&val, str));
*changes_offset = rev_offset + (apr_off_t)val;
}
return SVN_NO_ERROR;
}
/* Move a file into place from OLD_FILENAME in the transactions
directory to its final location NEW_FILENAME in the repository. On
Unix, match the permissions of the new file to the permissions of
PERMS_REFERENCE. Temporary allocations are from POOL.
This function almost duplicates svn_io_file_move(), but it tries to
guarantee a flush. */
static svn_error_t *
move_into_place(const char *old_filename,
const char *new_filename,
const char *perms_reference,
apr_pool_t *pool)
{
svn_error_t *err;
SVN_ERR(svn_io_copy_perms(perms_reference, old_filename, pool));
/* Move the file into place. */
err = svn_io_file_rename(old_filename, new_filename, pool);
if (err && APR_STATUS_IS_EXDEV(err->apr_err))
{
apr_file_t *file;
/* Can't rename across devices; fall back to copying. */
svn_error_clear(err);
err = SVN_NO_ERROR;
SVN_ERR(svn_io_copy_file(old_filename, new_filename, TRUE, pool));
/* Flush the target of the copy to disk. */
SVN_ERR(svn_io_file_open(&file, new_filename, APR_READ,
APR_OS_DEFAULT, pool));
/* ### BH: Does this really guarantee a flush of the data written
### via a completely different handle on all operating systems?
###
### Maybe we should perform the copy ourselves instead of making
### apr do that and flush the real handle? */
SVN_ERR(svn_io_file_flush_to_disk(file, pool));
SVN_ERR(svn_io_file_close(file, pool));
}
if (err)
return svn_error_trace(err);
#ifdef __linux__
{
/* Linux has the unusual feature that fsync() on a file is not
enough to ensure that a file's directory entries have been
flushed to disk; you have to fsync the directory as well.
On other operating systems, we'd only be asking for trouble
by trying to open and fsync a directory. */
const char *dirname;
apr_file_t *file;
dirname = svn_dirent_dirname(new_filename, pool);
SVN_ERR(svn_io_file_open(&file, dirname, APR_READ, APR_OS_DEFAULT,
pool));
SVN_ERR(svn_io_file_flush_to_disk(file, pool));
SVN_ERR(svn_io_file_close(file, pool));
}
#endif
return SVN_NO_ERROR;
}
( run in 0.464 second using v1.01-cache-2.11-cpan-39bf76dae61 )