/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999-2000, 2002, 2007-2010 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* It's a bit silly calling a swap partition a file system. Oh well... */
#include <config.h>
#if ENABLE_NLS
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
#include <unistd.h>
typedef struct {
/* ripped from mkswap */
typedef struct {
typedef struct {
union {
}* header;
void* buffer;
int buffer_size;
unsigned int page_count;
unsigned int version;
unsigned int max_bad_pages;
} SwapSpecific;
static PedGeometry*
{
/* Fail the swap-file-system-recognizing test when sector size
is not the default. */
return NULL;
switch (kind) {
/* Check for old style swap partitions. */
case 0:
break;
/* Check for new style swap partitions. */
case 1:
break;
/* Check for swap partitions containing swsusp data. */
case -1:
break;
/* Not reached. */
default:
goto error;
}
if (!fs)
goto error;
else
if (!probed_geom)
goto error_close_fs;
swap_close (fs);
return probed_geom;
swap_close (fs);
return NULL;
}
#ifndef DISCOVER_ONLY
static int
{
switch (kind) {
/* Check for old style swap partitions. */
case 0:
break;
/* Check for new style swap partitions. */
case 1:
break;
/* Check for swap partitions containing swsusp data. */
case -1:
break;
/* Not reached */
default:
goto error;
}
if (!fs)
return 1;
goto error_close_fs;
swap_close (fs);
return 1;
swap_close (fs);
return 0;
}
#endif /* !DISCOVER_ONLY */
static int
{
- sizeof (SwapNewHeader)) / 4;
if (fresh) {
/* version is always 1 here */
return 1;
}
else
0, fs_info->page_sectors);
}
static PedFileSystem*
{
if (!fs)
goto error;
if (!fs->type_specific)
goto error_free_fs;
goto error_free_type_specific;
goto error_free_header;
goto error_free_buffer;
return fs;
return NULL;
}
static void
{
}
static PedFileSystem*
{
const char* sig;
if (!fs)
goto error;
goto error_free_fs;
} else {
_sig [10] = 0;
_("Unrecognised old style linux swap signature '%10s'."), _sig);
goto error_free_fs;
}
return fs;
return NULL;
}
static PedFileSystem*
{
const char* sig;
if (!fs)
goto error;
/* swap_init (fs, 0); */
/* fs_info = SWAP_SPECIFIC (fs); */
/* if (!ped_geometry_read (fs->geom, fs_info->header, 0, */
/* fs_info->page_sectors)) */
goto error_free_fs;
} else {
_sig [10] = 0;
_("Unrecognised new style linux swap signature '%10s'."), _sig);
goto error_free_fs;
}
return fs;
return NULL;
}
static PedFileSystem*
{
const char* sig;
if (!fs)
goto error;
goto error_free_fs;
} else {
_sig [9] = 0;
_("Unrecognised swsusp linux swap signature '%9s'."), _sig);
goto error_free_fs;
}
return fs;
return NULL;
}
static int
{
return 1;
}
#ifndef DISCOVER_ONLY
static int
{
unsigned int i;
return i;
}
return 0;
}
static int
{
unsigned int pos;
if (!pos)
return 0;
}
return 1;
}
static int
{
char* ptr;
unsigned int mask;
} else {
if (ok) {
} else {
return 1;
> fs_info->max_bad_pages) {
_("Too many bad pages."));
return 0;
}
}
}
return 1;
}
static void
{
unsigned int i;
}
for (; i < 1024; i++) {
swap_mark_page (fs, i, 0);
}
}
}
static int
{
int stop_page = 0;
while (first_page <= last_page) {
* fs_info->page_sectors,
if (!result)
return 1;
return 0;
}
return 1;
}
static int
{
} else {
}
}
static PedFileSystem*
{
if (!fs)
goto error;
if (!swap_write (fs))
goto error_free_fs;
return fs;
return NULL;
}
static int
{
if (!swap_write (fs))
goto error;
return 1;
return 0;
}
static PedFileSystem*
{
}
static int
{
&& swap_write (fs);
}
static PedConstraint*
{
return NULL;
}
static PedConstraint*
{
}
static PedConstraint*
{
return swap_get_create_constraint (dev);
}
#endif /* !DISCOVER_ONLY */
static PedGeometry*
return _generic_swap_probe (geom, 0);
}
static PedGeometry*
}
static PedGeometry*
}
static int
return _generic_swap_clobber (geom, 0);
}
static int
}
static int
}
.probe = _swap_v0_probe,
#ifndef DISCOVER_ONLY
.open = _swap_v0_open,
.create = swap_create,
.close = swap_close,
.check = swap_check,
.resize = swap_resize,
#else
#endif /* !DISCOVER_ONLY */
};
.probe = _swap_v1_probe,
#ifndef DISCOVER_ONLY
.open = _swap_v1_open,
.create = swap_create,
.close = swap_close,
.check = swap_check,
.resize = swap_resize,
#else
#endif /* !DISCOVER_ONLY */
};
#ifndef DISCOVER_ONLY
.create = swap_create,
.close = swap_close,
.check = swap_check,
.resize = swap_resize,
#else
#endif /* !DISCOVER_ONLY */
};
.ops = &_swap_v0_ops,
.name = "linux-swap(v0)",
};
.ops = &_swap_v1_ops,
.name = "linux-swap(v1)",
};
.ops = &_swap_swsusp_ops,
.name = "swsusp",
};
void
{
}
void
{
}