From b8103bbcfecc7378ab45ed65ef249d5cb8c8b270 Mon Sep 17 00:00:00 2001 From: Erik Larsson Date: Mon, 12 Sep 2011 09:07:00 +0200 Subject: [PATCH] Permit $VOLUME_NAME to be 0-sized, even when $AttrDef says otherwise. When clearing a volume name in Windows, $VOLUME_NAME is set to size 0, even if the standard $AttrDef says that the minimum size is 2. So the definition in $AttrDef doesn't reflect actual Windows behaviour in this particular case, and to clear volume names ourselves the way Windows does it, we must must add a special rule to permit us to truncate the $VOLUME_NAME attribute to 0 even when $AttrDef specifies a higher value as minimum size. --- libntfs-3g/attrib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 1d5eb57b..b790908c 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -3547,6 +3547,14 @@ int ntfs_attr_size_bounds_check(const ntfs_volume *vol, const ATTR_TYPES type, min_size = sle64_to_cpu(ad->min_size); max_size = sle64_to_cpu(ad->max_size); + + /* The $AttrDef generated by Windows specifies 2 as min_size for the + * volume name attribute, but in reality Windows sets it to 0 when + * clearing the volume name. If we want to be able to clear the volume + * name we must also accept 0 as min_size, despite the $AttrDef + * definition. */ + if(type == AT_VOLUME_NAME) + min_size = 0; if ((min_size && (size < min_size)) || ((max_size > 0) && (size > max_size))) {