| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | 
|  | 3 | * All Rights Reserved. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or | 
|  | 6 | * modify it under the terms of the GNU General Public License as | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. | 
|  | 8 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, | 
|  | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12 | * GNU General Public License for more details. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License | 
|  | 15 | * along with this program; if not, write the Free Software Foundation, | 
|  | 16 | * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <xfs.h> | 
|  | 19 |  | 
| Christoph Hellwig | 794fe2d | 2006-01-11 15:37:17 +1100 | [diff] [blame] | 20 | /* IRIX interpretation of an uuid_t */ | 
|  | 21 | typedef struct { | 
|  | 22 | __be32	uu_timelow; | 
|  | 23 | __be16	uu_timemid; | 
|  | 24 | __be16	uu_timehi; | 
|  | 25 | __be16	uu_clockseq; | 
|  | 26 | __be16	uu_node[3]; | 
|  | 27 | } xfs_uu_t; | 
|  | 28 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | /* | 
|  | 30 | * uuid_getnodeuniq - obtain the node unique fields of a UUID. | 
|  | 31 | * | 
|  | 32 | * This is not in any way a standard or condoned UUID function; | 
|  | 33 | * it just something that's needed for user-level file handles. | 
|  | 34 | */ | 
|  | 35 | void | 
|  | 36 | uuid_getnodeuniq(uuid_t *uuid, int fsid [2]) | 
|  | 37 | { | 
| Christoph Hellwig | 794fe2d | 2006-01-11 15:37:17 +1100 | [diff] [blame] | 38 | xfs_uu_t *uup = (xfs_uu_t *)uuid; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 |  | 
| Christoph Hellwig | 794fe2d | 2006-01-11 15:37:17 +1100 | [diff] [blame] | 40 | fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) | | 
|  | 41 | be16_to_cpu(uup->uu_timemid); | 
| Nathan Scott | a780143 | 2006-03-14 13:24:46 +1100 | [diff] [blame] | 42 | fsid[1] = be32_to_cpu(uup->uu_timelow); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | } | 
|  | 44 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | int | 
|  | 46 | uuid_is_nil(uuid_t *uuid) | 
|  | 47 | { | 
|  | 48 | int	i; | 
|  | 49 | char	*cp = (char *)uuid; | 
|  | 50 |  | 
|  | 51 | if (uuid == NULL) | 
|  | 52 | return 0; | 
|  | 53 | /* implied check of version number here... */ | 
|  | 54 | for (i = 0; i < sizeof *uuid; i++) | 
|  | 55 | if (*cp++) return 0;	/* not nil */ | 
|  | 56 | return 1;	/* is nil */ | 
|  | 57 | } | 
|  | 58 |  | 
|  | 59 | int | 
|  | 60 | uuid_equal(uuid_t *uuid1, uuid_t *uuid2) | 
|  | 61 | { | 
|  | 62 | return memcmp(uuid1, uuid2, sizeof(uuid_t)) ? 0 : 1; | 
|  | 63 | } |