ntfs.c revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2000, 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/>.
*/
#include <config.h>
#if ENABLE_NLS
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
#include <unistd.h>
#include <string.h>
#include <limits.h> /* for PATH_MAX */
#define NTFS_SIGNATURE "NTFS"
#define NTFSRESIZE_CMD_PATH "ntfsresize"
#define NTFSCREATE_CMD_PATH "mkntfs"
#define NTFSFIX_CMD_PATH "ntfsfix"
#define NTFSCLONE_CMD_PATH "ntfsclone"
static PedFileSystemType ntfs_type;
static PedGeometry*
{
char buf[512];
return 0;
PED_LE64_TO_CPU (*(uint64_t*)
(buf + 0x28)));
else
return NULL;
}
#ifndef DISCOVER_ONLY
static int
{
char buf[512];
}
static PedFileSystem*
{
if (!fs)
return NULL;
return fs;
}
/*
* Returns partition number (1..4) that contains geom, 0 otherwise.
*/
static int
{
int partnum = 0;
if (!disk) {
printf("_get_partition_num_by_geom: ped_disk_new failed!\n");
}
else {
printf("_get_partition_num_by_geom: "
"ped_disk_get_partition_by_sector failed!\n");
}
else {
}
}
return partnum;
}
/*
* return the partition device name for geom in partpath.
* return 1 on success, 0 on failure.
*/
static int
{
int partnum;
if (!partnum)
return 0;
/*
* XXX Solaris specific
* Create the path name to the *pn device, where n is the partition #
* geom->dev->path looks like this: "/devices/.../cmdk@0,0:q"
* :r is p1, :s is p2, :t is p3, :u is p4
* 'q' + 1 == 'r'
* '0' + 1 == '1'
*/
return 1;
}
/*
* Executes cmd in a pipe.
* Returns -1 on popen failure or the return value from pclose.
* Saves the output from cmd in bigbuf for later display.
*/
static int
{
char buf[512];
int szbigbuf;
return -1;
if (szbigbuf > 0) {
}
}
}
/*
* Returns new fs on success, NULL on failure.
*/
{
int x;
goto error;
(PedSector) 0, /* partition start sector */
partpath);
/*
* Use system() so the output that shows progress is displayed.
*/
if (x != 0) {
goto error;
}
if (!fs)
goto error;
return fs;
}
/*
* Returns 1 on success, 0 on failure.
*/
static int
{
return 1;
}
/*
* Returns 1 on success, 0 on failure.
*/
static int
{
int x;
int ret = 0;
goto error;
/*
* Use system() so the output that shows progress is displayed.
*/
if (x == 0) {
}
else {
goto error;
}
return ret;
}
/*
* Copy from source fs to destination geom.
* The destination partition must alreay exist.
* ntfsclone --overwrite destination-device source-device
* Returns new fs on success, NULL on failure.
*/
static PedFileSystem*
{
int x;
goto error;
goto error;
/*
* Use system() so the output that shows progress is displayed.
*/
if (x != 0) {
goto error;
}
goto error;
return new_fs;
}
/*
* fs->geom has the current filesystem size in sectors.
* geom has the new, requested filesystem size in sectors.
*
* fs->geom->dev is the same object as geom->dev.
* geom->dev->path looks like this:
* or this:
* /devices/.../cmdk@0,0:q
*
* The ntfsresize cmd wants the block disk device, not the raw one.
* It also wants the partition device, not the whole disk.
*
* Returns 1 on success, 0 on failure.
*/
static int
{
int x;
int ret = 0; /* this tells the upper layer NOT to resize partition */
_("Sorry, can't move the start of "
"ntfs partitions yet."));
return 0;
}
}
}
else {
}
goto error1;
/*
* ntfsresize -f says don't worry about consistency flag
*/
if (x != 0) {
goto error2;
}
if (x != 0) {
goto error2;
}
/*
* ntfsresize -f -f means don't ask "Are you sure?"
* Use system() so the output that shows progress is displayed.
*/
if (x == 0) {
}
else {
goto error2;
}
return ret;
}
/*
* return the minimum resize size from the ntfsresize external cmd
* in blocks, 0 on error.
* Saves the output from cmd in bigbuf for later display.
*/
static PedSector
_get_min_from_ntfsresize(const char *cmd)
{
char buf[512];
int x;
int szbigbuf;
return 0;
if (szbigbuf > 0) {
}
if (x > 0)
break;
}
return size;
}
/*
* return the minimum resize size in blocks, fs->geom->length on error.
*/
static PedSector
{
return max_length;
if (length == 0) {
return max_length;
}
}
{
return NULL;
}
{
}
#endif /* !DISCOVER_ONLY */
static PedFileSystemOps ntfs_ops = {
.probe = ntfs_probe,
#ifndef DISCOVER_ONLY
.clobber = ntfs_clobber,
.create = ntfs_create,
.close = ntfs_close,
.check = ntfs_check,
.resize = ntfs_resize,
#else
#endif
};
static PedFileSystemType ntfs_type = {
.name = "ntfs",
};
void
{
}
void
{
}