/* loopback.c - command to add loopback devices. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
struct grub_loopback
{
char *devname;
};
{
{0, 0, 0, 0, 0, 0}
};
/* Delete the loopback device NAME. */
static grub_err_t
{
/* Search for the device. */
dev;
break;
if (! dev)
/* Remove the device from the list. */
return 0;
}
/* The command to add and remove loopback devices. */
static grub_err_t
{
if (argc < 1)
/* Check if `-d' was used. */
return delete_loopback (args[0]);
if (argc < 2)
if (! file)
return grub_errno;
/* First try to replace the old device. */
break;
if (newdev)
{
return 0;
}
/* Unable to replace it, make a new entry. */
if (! newdev)
goto fail;
{
goto fail;
}
/* Add the new entry to the list. */
return 0;
fail:
ret = grub_errno;
return ret;
}
static int
{
struct grub_loopback *d;
if (pull != GRUB_DISK_PULL_NONE)
return 0;
for (d = loopback_list; d; d = d->next)
{
return 1;
}
return 0;
}
static grub_err_t
{
break;
if (! dev)
/* Use the filesize for the disk size, round up to a complete sector. */
else
return 0;
}
static grub_err_t
{
if (grub_errno)
return grub_errno;
/* In case there is more data read than there is available, in case
of files that are not a multiple of GRUB_DISK_SECTOR_SIZE, fill
the rest with zeros. */
{
}
return 0;
}
static grub_err_t
{
return GRUB_ERR_NOT_IMPLEMENTED_YET;
}
{
.name = "loopback",
.next = 0
};
{
N_("[-d] DEVICENAME FILE."),
}
{
}