[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/10] tests: add FS-resize test driver
From: |
Jim Meyering |
Subject: |
[PATCH 08/10] tests: add FS-resize test driver |
Date: |
Fri, 3 Feb 2012 22:46:57 +0100 |
From: Christoph Hellwig <address@hidden>
* tests/fs-resize.c: New file, to test FAT/HFS resizing.
---
tests/fs-resize.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
create mode 100644 tests/fs-resize.c
diff --git a/tests/fs-resize.c b/tests/fs-resize.c
new file mode 100644
index 0000000..90bb4c3
--- /dev/null
+++ b/tests/fs-resize.c
@@ -0,0 +1,76 @@
+
+#include <config.h>
+#include <stdbool.h>
+
+#include "closeout.h"
+#include "configmake.h"
+
+#include <parted/parted.h>
+#include <parted/debug.h>
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include "xalloc.h"
+
+int main(int argc, char **argv)
+{
+ PedSector start = 0, len = 0;
+ PedGeometry geom, new_geom;
+ PedDevice *dev;
+ PedFileSystem *fs;
+ PedTimer *g_timer = NULL;
+
+ if (argc != 2 && argc != 4) {
+ fprintf(stderr, "usage: %s <device>\n"
+ " %s <device> <start> <length>\n",
+ argv[0], argv[0]);
+ return 1;
+ }
+
+ dev = ped_device_get(argv[1]);
+ if (!dev) {
+ fprintf(stderr, "cannot create device %s\n", argv[1]);
+ return 1;
+ }
+
+ if (!ped_device_open(dev)) {
+ fprintf(stderr, "cannot open device %s\n", argv[1]);
+ return 1;
+ }
+
+ if (!ped_geometry_init(&geom, dev, 0, dev->length)) {
+ fprintf(stderr, "cannot initialize geometry\n");
+ return 1;
+ }
+
+ if (argc > 2) {
+ start = strtoll(argv[2], NULL, 0);
+ len = strtoll(argv[3], NULL, 0);
+ } else {
+ start = 0;
+ len = dev->length;
+ }
+
+ if (!ped_geometry_init(&new_geom, dev, start, len)) {
+ fprintf(stderr, "cannot initialize new geometry\n");
+ return 1;
+ }
+
+ fs = ped_file_system_open(&geom);
+ if (!fs) {
+ fprintf(stderr, "cannot read fs\n");
+ return 1;
+ }
+
+ if (!ped_file_system_resize(fs, &new_geom, g_timer)) {
+ fprintf(stderr, "cannot resize filesystem\n");
+ return 1;
+ }
+
+ ped_file_system_close(fs);
+ return 0;
+}
--
1.7.9.112.gb85f2
- libparted-fs-resize: HFS/FAT file system resizing library, Jim Meyering, 2012/02/03
- [PATCH 01/10] maint: remove now-unused fat-related functions, Jim Meyering, 2012/02/03
- [PATCH 07/10] lib-fs-resize: use linker script to expose only selected functions, Jim Meyering, 2012/02/03
- [PATCH 03/10] update copyrights in r/, Jim Meyering, 2012/02/03
- [PATCH 04/10] lib-fs-resize: add wrappers for open, close, resize, get_resize_constraint, Jim Meyering, 2012/02/03
- [PATCH 05/10] lib-fs-resize: rewrite ped_file_system_clobber, Jim Meyering, 2012/02/03
- [PATCH 10/10] doc: mention HFS+/FAT file system resizing in NEWS, Jim Meyering, 2012/02/03
- [PATCH 09/10] tests: test FAT and HFS file system resizing, Jim Meyering, 2012/02/03
- [PATCH 08/10] tests: add FS-resize test driver,
Jim Meyering <=
- [PATCH 06/10] maint: remove r/hfs/DOC,HISTORY,TODO; add VERSION for new library, Jim Meyering, 2012/02/03
- [PATCH 02/10] lib-fs-resize: re-add HFS and FAT file-system-related code, Jim Meyering, 2012/02/03
- Re: libparted-fs-resize: HFS/FAT file system resizing library, Curtis Gedak, 2012/02/03
- Re: libparted-fs-resize: HFS/FAT file system resizing library, Curtis Gedak, 2012/02/04