~ubuntu-branches/debian/sid/ntfs-3g/sid

« back to all changes in this revision

Viewing changes to libntfs-3g/attrib.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2014-10-05 09:34:12 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20141005093412-4ohtygxt9pm9v5u9
Tags: 1:2014.2.15AR.2-1
* New upstream release.
* Remove 0001-type-inconsistencies.patch and 0002-exit-values.patch , this
  release contains those.
* Update Standards-Version to 3.9.6 .

Show diffs side-by-side

added added

removed removed

Lines of Context:
6735
6735
        return res;
6736
6736
}
6737
6737
 
 
6738
/*
 
6739
 *              Shrink the size of a data attribute if needed
 
6740
 *
 
6741
 *      For non-resident attributes only.
 
6742
 *      The space remains allocated.
 
6743
 *
 
6744
 *      Returns 0 if successful
 
6745
 *              -1 if failed, with errno telling why
 
6746
 */
 
6747
 
 
6748
 
 
6749
int ntfs_attr_shrink_size(ntfs_inode *ni, ntfschar *stream_name,
 
6750
                int stream_name_len, off_t offset)
 
6751
{
 
6752
        ntfs_attr_search_ctx *ctx;
 
6753
        ATTR_RECORD *a;
 
6754
        int res;
 
6755
 
 
6756
        res = -1;
 
6757
        ctx = ntfs_attr_get_search_ctx(ni, NULL);
 
6758
        if (ctx) {
 
6759
                if (!ntfs_attr_lookup(AT_DATA, stream_name, stream_name_len,
 
6760
                        CASE_SENSITIVE, 0, NULL, 0, ctx)) {
 
6761
                        a = ctx->attr;
 
6762
 
 
6763
                        if (a->non_resident
 
6764
                            && (sle64_to_cpu(a->initialized_size) > offset)) {
 
6765
                                a->initialized_size = cpu_to_le64(offset);
 
6766
                                a->data_size = a->initialized_size;
 
6767
                        }
 
6768
                        res = 0;
 
6769
                }
 
6770
                ntfs_attr_put_search_ctx(ctx);
 
6771
        }
 
6772
        return (res);
 
6773
}
6738
6774
 
6739
6775
int ntfs_attr_exist(ntfs_inode *ni, const ATTR_TYPES type, const ntfschar *name,
6740
6776
                    u32 name_len)