simplified ntfs_generate_guid()

edge.strict_endians
szaka 2005-11-01 21:09:52 +00:00
parent 987f33e5df
commit c10f046225
3 changed files with 9 additions and 14 deletions

View File

@ -50,6 +50,6 @@ static __inline__ BOOL ntfs_sid_is_valid(const SID *sid)
extern int ntfs_sid_to_mbs_size(const SID *sid);
extern char *ntfs_sid_to_mbs(const SID *sid, char *sid_str,
size_t sid_str_size);
extern GUID *ntfs_generate_guid(GUID *guid);
extern void ntfs_generate_guid(GUID *guid);
#endif /* defined _NTFS_SECURITY_H */

View File

@ -252,26 +252,21 @@ err_out:
/**
* ntfs_generate_guid - generatates a random current guid.
* @guid: a pointer to a GUID struct to hold the generated guid.
* @guid: [OUT] pointer to a GUID struct to hold the generated guid.
*
* perhaps not a very good random number generator though...
*
* Returns: The same pointer it was given as a parameter (guid).
*/
GUID *ntfs_generate_guid(GUID *guid)
void ntfs_generate_guid(GUID *guid)
{
int i;
static u8 array[16];
u8 *p = (u8 *)guid;
for (i = 0; i < 16; i++) {
array[i] = (u8)(random() & 0xFF);
for (i = 0; i < sizeof(GUID); i++) {
p[i] = (u8)(random() & 0xFF);
if (i == 7)
array[7] = (array[7] & 0x0F) | 0x40;
p[7] = (p[7] & 0x0F) | 0x40;
if (i == 8)
array[8] = (array[8] & 0x3F) | 0x80;
p[8] = (p[8] & 0x3F) | 0x80;
}
memcpy(guid, array, sizeof(guid));
return guid;
}

View File

@ -4202,7 +4202,7 @@ static void create_file_volume(MFT_RECORD *m, MFT_REF root_ref, VOLUME_FLAGS fl)
}
if (!err && vol->major_ver>=3) {
volume_obj_id=(OBJECT_ID_ATTR*)calloc(1,0x10);
volume_obj_id->object_id = *ntfs_generate_guid(&volume_obj_id->object_id);
ntfs_generate_guid(&volume_obj_id->object_id);
err = add_attr_object_id(m, volume_obj_id, 0x10);
}
if (!err)