diff --git a/ChangeLog b/ChangeLog index ac63eafe0..54684fe51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2013-09-23 Vladimir Serbinenko + + * include/grub/cryptodisk.h (grub_cryptodisk): Use grub_util_fd_t + for cheat_fd. + * grub-core/disk/cryptodisk.c (grub_cryptodisk_open): Use grub_util_* + functions. + (grub_cryptodisk_cheat_insert): Likewise. + (grub_cryptodisk_close): Likewise. + 2013-09-23 Vladimir Serbinenko * include/grub/emu/misc.h: Remove leftover cygwin definitions. diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 456c60846..f291ea698 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -504,9 +504,9 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk) #ifdef GRUB_UTIL if (dev->cheat) { - if (dev->cheat_fd == -1) - dev->cheat_fd = open (dev->cheat, O_RDONLY); - if (dev->cheat_fd == -1) + if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd)) + dev->cheat_fd = grub_util_fd_open (dev->cheat, O_RDONLY); + if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd)) return grub_error (GRUB_ERR_IO, N_("cannot open `%s': %s"), dev->cheat, strerror (errno)); } @@ -541,8 +541,8 @@ grub_cryptodisk_close (grub_disk_t disk) #ifdef GRUB_UTIL if (dev->cheat) { - close (dev->cheat_fd); - dev->cheat_fd = -1; + grub_util_fd_close (dev->cheat_fd); + dev->cheat_fd = GRUB_UTIL_FD_INVALID; } #endif grub_disk_close (dev->source_disk); @@ -735,7 +735,7 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, return grub_errno; } - newdev->cheat_fd = -1; + newdev->cheat_fd = GRUB_UTIL_FD_INVALID; newdev->source_id = source->id; newdev->source_dev_id = source->dev->id; newdev->id = n++; diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h index c3ee82004..09e65721d 100644 --- a/include/grub/cryptodisk.h +++ b/include/grub/cryptodisk.h @@ -22,6 +22,9 @@ #include #include #include +#ifdef GRUB_UTIL +#include +#endif typedef enum { @@ -85,7 +88,7 @@ struct grub_cryptodisk grub_size_t keysize; #ifdef GRUB_UTIL char *cheat; - int cheat_fd; + grub_util_fd_t cheat_fd; #endif const char *modname; int log_sector_size;