linux_swap.c revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999, 2000, 2002, 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.
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>
#define BUFFER_SIZE 128
typedef struct {
char page_map[1];
/* ripped from mkswap */
typedef struct {
unsigned char sws_uuid[16];
unsigned char sws_volume[16];
typedef struct {
union {
}* header;
void* buffer;
int buffer_size;
unsigned int page_count;
unsigned int version;
unsigned int max_bad_pages;
} SwapSpecific;
static PedFileSystemType swap_type;
static PedGeometry*
{
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
{
char buf[512];
if (!fs)
return 1;
goto error_close_fs;
swap_close (fs);
return 1;
swap_close (fs);
return 0;
}
#endif /* !DISCOVER_ONLY */
static void
{
- sizeof (SwapNewHeader)) / 4;
if (fresh)
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 {
char _sig [11];
_sig [10] = 0;
_("Unrecognised linux swap signature '%10s'."), _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 first_page = 1;
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 PedFileSystemOps swap_ops = {
.probe = swap_probe,
#ifndef DISCOVER_ONLY
.clobber = swap_clobber,
.create = swap_create,
.close = swap_close,
.check = swap_check,
.resize = swap_resize,
#else
#endif /* !DISCOVER_ONLY */
};
static PedFileSystemType swap_type = {
.name = "linux-swap",
};
void
{
}
void
{
}