/* loadenv.c - command to load/save environment variable. */
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2008,2009 Free Software Foundation, Inc.
+ * Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
}
}
-static int
+static grub_err_t
check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
grub_file_t file)
{
{
/* This might be actually valid, but it is unbelievable that
any filesystem makes such a silly allocation. */
- grub_error (GRUB_ERR_BAD_FS, "malformed file");
- return 0;
+ return grub_error (GRUB_ERR_BAD_FS, "malformed file");
}
}
if (total_length != grub_file_size (file))
{
/* Maybe sparse, unallocated sectors. No way in GRUB. */
- grub_error (GRUB_ERR_BAD_FILE_TYPE, "sparse file not allowed");
- return 0;
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "sparse file not allowed");
}
/* One more sanity check. Re-read all sectors by blocklists, and compare
if (grub_disk_read (disk, p->sector - part_start,
p->offset, p->length, blockbuf))
- return 0;
+ return grub_errno;
if (grub_memcmp (buf + index, blockbuf, p->length) != 0)
- {
- grub_error (GRUB_ERR_FILE_READ_ERROR, "invalid blocklist");
- return 0;
- }
+ return grub_error (GRUB_ERR_FILE_READ_ERROR, "invalid blocklist");
}
- return 1;
+ return GRUB_ERR_NONE;
}
static int
if (! envblk)
goto fail;
- if (! check_blocklists (envblk, head, file))
+ if (check_blocklists (envblk, head, file))
goto fail;
while (argc)