7 /* file ID printable representation
9 /* #include <file_id.h>
11 /* const char *get_file_id(fd)
14 /* int check_file_id(fd, id)
18 /* get_file_id() queries the operating system for the unique identifier
19 /* for the specified file and returns a printable representation.
20 /* The result is volatile. Make a copy if it is to be used for any
21 /* appreciable amount of time.
23 /* check_file_id() tests if an open file matches the given
24 /* printable FILE ID representation.
28 /* A valid file descriptor that is associated with an open file.
32 /* All errors are fatal.
36 /* The Secure Mailer license must be distributed with this software.
39 /* IBM T.J. Watson Research
41 /* Yorktown Heights, NY 10598, USA
59 /* get_file_id - lookup file ID, convert to printable form */
61 const char *get_file_id(int fd
)
63 static VSTRING
*result
;
67 result
= vstring_alloc(1);
68 if (fstat(fd
, &st
) < 0)
69 msg_fatal("fstat: %m");
70 vstring_sprintf(result
, "%lX", (long) st
.st_ino
);
71 return (vstring_str(result
));
74 /* check_file_id - make sure file name matches ID */
76 int check_file_id(int fd
, const char *name
)
78 return (strcmp(get_file_id(fd
), name
));