ia64/xen-unstable

changeset 14015:89ca591a2c21

Filesystem implementations may need optional arguments in terms of
what to mount. Add an options string to the libfsimage API.

Signed-off-by: John Levon <john.levon@sun.com>
author john.levon@sun.com
date Mon Feb 19 20:44:42 2007 -0800 (2007-02-19)
parents b83cfb117bdd
children d2dff286994d 919879a49266
files tools/libfsimage/common/fsimage.c tools/libfsimage/common/fsimage.h tools/libfsimage/common/fsimage_grub.c tools/libfsimage/common/fsimage_grub.h tools/libfsimage/common/fsimage_plugin.c tools/libfsimage/common/fsimage_plugin.h tools/libfsimage/common/fsimage_priv.h tools/libfsimage/ext2fs-lib/ext2fs-lib.c tools/libfsimage/ext2fs/fsys_ext2fs.c tools/libfsimage/reiserfs/fsys_reiserfs.c tools/libfsimage/ufs/fsys_ufs.c tools/pygrub/src/fsimage/fsimage.c
line diff
     1.1 --- a/tools/libfsimage/common/fsimage.c	Mon Feb 19 22:50:07 2007 +0000
     1.2 +++ b/tools/libfsimage/common/fsimage.c	Mon Feb 19 20:44:42 2007 -0800
     1.3 @@ -36,7 +36,7 @@
     1.4  
     1.5  static pthread_mutex_t fsi_lock = PTHREAD_MUTEX_INITIALIZER;
     1.6  
     1.7 -fsi_t *fsi_open_fsimage(const char *path, uint64_t off)
     1.8 +fsi_t *fsi_open_fsimage(const char *path, uint64_t off, const char *options)
     1.9  {
    1.10  	fsi_t *fsi = NULL;
    1.11  	int fd;
    1.12 @@ -53,7 +53,7 @@ fsi_t *fsi_open_fsimage(const char *path
    1.13  	fsi->f_data = NULL;
    1.14  
    1.15  	pthread_mutex_lock(&fsi_lock);
    1.16 -	err = find_plugin(fsi, path);
    1.17 +	err = find_plugin(fsi, path, options);
    1.18  	pthread_mutex_unlock(&fsi_lock);
    1.19  	if (err != 0)
    1.20  		goto fail;
     2.1 --- a/tools/libfsimage/common/fsimage.h	Mon Feb 19 22:50:07 2007 +0000
     2.2 +++ b/tools/libfsimage/common/fsimage.h	Mon Feb 19 20:44:42 2007 -0800
     2.3 @@ -35,7 +35,7 @@ extern C {
     2.4  typedef struct fsi fsi_t;
     2.5  typedef struct fsi_file fsi_file_t;
     2.6  
     2.7 -fsi_t *fsi_open_fsimage(const char *, uint64_t);
     2.8 +fsi_t *fsi_open_fsimage(const char *, uint64_t, const char *);
     2.9  void fsi_close_fsimage(fsi_t *);
    2.10  
    2.11  int fsi_file_exists(fsi_t *, const char *);
     3.1 --- a/tools/libfsimage/common/fsimage_grub.c	Mon Feb 19 22:50:07 2007 +0000
     3.2 +++ b/tools/libfsimage/common/fsimage_grub.c	Mon Feb 19 20:44:42 2007 -0800
     3.3 @@ -161,7 +161,7 @@ fsig_substring(const char *s1, const cha
     3.4  }
     3.5  
     3.6  static int
     3.7 -fsig_mount(fsi_t *fsi, const char *path)
     3.8 +fsig_mount(fsi_t *fsi, const char *path, const char *options)
     3.9  {
    3.10  	fsig_plugin_ops_t *ops = fsi->f_plugin->fp_data;
    3.11  	fsi_file_t *ffi;
    3.12 @@ -178,7 +178,7 @@ fsig_mount(fsi_t *fsi, const char *path)
    3.13  
    3.14  	bzero(fsi->f_data, sizeof (fsig_data_t));
    3.15  
    3.16 -	if (!ops->fpo_mount(ffi)) {
    3.17 +	if (!ops->fpo_mount(ffi, options)) {
    3.18  		fsip_file_free(ffi);
    3.19  		free(fsi->f_data);
    3.20  		fsi->f_data = NULL;
     4.1 --- a/tools/libfsimage/common/fsimage_grub.h	Mon Feb 19 22:50:07 2007 +0000
     4.2 +++ b/tools/libfsimage/common/fsimage_grub.h	Mon Feb 19 20:44:42 2007 -0800
     4.3 @@ -38,7 +38,7 @@ extern C {
     4.4  
     4.5  typedef struct fsig_plugin_ops {
     4.6  	int fpo_version;
     4.7 -	int (*fpo_mount)(fsi_file_t *);
     4.8 +	int (*fpo_mount)(fsi_file_t *, const char *);
     4.9  	int (*fpo_dir)(fsi_file_t *, char *);
    4.10  	int (*fpo_read)(fsi_file_t *, char *, int);
    4.11  } fsig_plugin_ops_t;
     5.1 --- a/tools/libfsimage/common/fsimage_plugin.c	Mon Feb 19 22:50:07 2007 +0000
     5.2 +++ b/tools/libfsimage/common/fsimage_plugin.c	Mon Feb 19 20:44:42 2007 -0800
     5.3 @@ -185,7 +185,7 @@ fail:
     5.4  	return (ret);
     5.5  }
     5.6  
     5.7 -int find_plugin(fsi_t *fsi, const char *path)
     5.8 +int find_plugin(fsi_t *fsi, const char *path, const char *options)
     5.9  {
    5.10  	fsi_plugin_t *fp;
    5.11  	int ret = 0;
    5.12 @@ -195,7 +195,7 @@ int find_plugin(fsi_t *fsi, const char *
    5.13  
    5.14  	for (fp = plugins; fp != NULL; fp = fp->fp_next) {
    5.15  		fsi->f_plugin = fp;
    5.16 -		if (fp->fp_ops->fpo_mount(fsi, path) == 0)
    5.17 +		if (fp->fp_ops->fpo_mount(fsi, path, options) == 0)
    5.18  			goto out;
    5.19  	}
    5.20  
     6.1 --- a/tools/libfsimage/common/fsimage_plugin.h	Mon Feb 19 22:50:07 2007 +0000
     6.2 +++ b/tools/libfsimage/common/fsimage_plugin.h	Mon Feb 19 20:44:42 2007 -0800
     6.3 @@ -38,7 +38,7 @@ typedef struct fsi_plugin fsi_plugin_t;
     6.4  
     6.5  typedef struct fsi_plugin_ops {
     6.6  	int fpo_version;
     6.7 -	int (*fpo_mount)(fsi_t *, const char *);
     6.8 +	int (*fpo_mount)(fsi_t *, const char *, const char *);
     6.9  	int (*fpo_umount)(fsi_t *);
    6.10  	fsi_file_t *(*fpo_open)(fsi_t *, const char *);
    6.11  	ssize_t (*fpo_read)(fsi_file_t *, void *, size_t);
     7.1 --- a/tools/libfsimage/common/fsimage_priv.h	Mon Feb 19 22:50:07 2007 +0000
     7.2 +++ b/tools/libfsimage/common/fsimage_priv.h	Mon Feb 19 20:44:42 2007 -0800
     7.3 @@ -53,7 +53,7 @@ struct fsi_file {
     7.4  	void *ff_data;
     7.5  };
     7.6  
     7.7 -int find_plugin(fsi_t *, const char *);
     7.8 +int find_plugin(fsi_t *, const char *, const char *);
     7.9  
    7.10  #ifdef __cplusplus
    7.11  };
     8.1 --- a/tools/libfsimage/ext2fs-lib/ext2fs-lib.c	Mon Feb 19 22:50:07 2007 +0000
     8.2 +++ b/tools/libfsimage/ext2fs-lib/ext2fs-lib.c	Mon Feb 19 20:44:42 2007 -0800
     8.3 @@ -27,7 +27,7 @@
     8.4  #include <inttypes.h>
     8.5  
     8.6  static int
     8.7 -ext2lib_mount(fsi_t *fsi, const char *name)
     8.8 +ext2lib_mount(fsi_t *fsi, const char *name, const char *options)
     8.9  {
    8.10  	int err;
    8.11  	char opts[30] = "";
     9.1 --- a/tools/libfsimage/ext2fs/fsys_ext2fs.c	Mon Feb 19 22:50:07 2007 +0000
     9.2 +++ b/tools/libfsimage/ext2fs/fsys_ext2fs.c	Mon Feb 19 20:44:42 2007 -0800
     9.3 @@ -321,7 +321,7 @@ ffz (unsigned long word)
     9.4  
     9.5  /* check filesystem types and read superblock into memory buffer */
     9.6  int
     9.7 -ext2fs_mount (fsi_file_t *ffi)
     9.8 +ext2fs_mount (fsi_file_t *ffi, const char *options)
     9.9  {
    9.10    int retval = 1;
    9.11  
    10.1 --- a/tools/libfsimage/reiserfs/fsys_reiserfs.c	Mon Feb 19 22:50:07 2007 +0000
    10.2 +++ b/tools/libfsimage/reiserfs/fsys_reiserfs.c	Mon Feb 19 20:44:42 2007 -0800
    10.3 @@ -633,7 +633,7 @@ journal_init (fsi_file_t *ffi)
    10.4  
    10.5  /* check filesystem types and read superblock into memory buffer */
    10.6  int
    10.7 -reiserfs_mount (fsi_file_t *ffi)
    10.8 +reiserfs_mount (fsi_file_t *ffi, const char *options)
    10.9  {
   10.10    struct reiserfs_super_block super;
   10.11    int superblock = REISERFS_DISK_OFFSET_IN_BYTES >> SECTOR_BITS;
    11.1 --- a/tools/libfsimage/ufs/fsys_ufs.c	Mon Feb 19 22:50:07 2007 +0000
    11.2 +++ b/tools/libfsimage/ufs/fsys_ufs.c	Mon Feb 19 20:44:42 2007 -0800
    11.3 @@ -44,7 +44,7 @@ static grub_daddr32_t sbmap(fsi_file_t *
    11.4  
    11.5  /* read superblock and check fs magic */
    11.6  int
    11.7 -ufs_mount(fsi_file_t *ffi)
    11.8 +ufs_mount(fsi_file_t *ffi, const char *options)
    11.9  {
   11.10  	if (/*! IS_PC_SLICE_TYPE_SOLARIS(current_slice) || */
   11.11  	    !devread(ffi, UFS_SBLOCK, 0, UFS_SBSIZE, (char *)SUPERBLOCK) ||
    12.1 --- a/tools/pygrub/src/fsimage/fsimage.c	Mon Feb 19 22:50:07 2007 +0000
    12.2 +++ b/tools/pygrub/src/fsimage/fsimage.c	Mon Feb 19 20:44:42 2007 -0800
    12.3 @@ -260,19 +260,20 @@ PyTypeObject fsimage_fs_type = {
    12.4  static PyObject *
    12.5  fsimage_open(PyObject *o, PyObject *args, PyObject *kwargs)
    12.6  {
    12.7 -	static char *kwlist[] = { "name", "offset", NULL };
    12.8 -	char * name;
    12.9 +	static char *kwlist[] = { "name", "offset", "options", NULL };
   12.10 +	char *name;
   12.11 +	char *options = NULL;
   12.12  	uint64_t offset = 0;
   12.13  	fsimage_fs_t *fs;
   12.14  
   12.15 -	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|L", kwlist, 
   12.16 -	    &name, &offset))
   12.17 +	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|Ls", kwlist, 
   12.18 +	    &name, &offset, &options))
   12.19  		return (NULL);
   12.20  
   12.21  	if ((fs = PyObject_NEW(fsimage_fs_t, &fsimage_fs_type)) == NULL)
   12.22  		return (NULL);
   12.23  
   12.24 -	if ((fs->fs = fsi_open_fsimage(name, offset)) == NULL) {
   12.25 +	if ((fs->fs = fsi_open_fsimage(name, offset, options)) == NULL) {
   12.26  		PyErr_SetFromErrno(PyExc_IOError);
   12.27  		return (NULL);
   12.28  	}
   12.29 @@ -284,7 +285,8 @@ PyDoc_STRVAR(fsimage_open__doc__,
   12.30      "open(name, [offset=off]) - Open the given file as a filesystem image.\n"
   12.31      "\n"
   12.32      "name - name of file to open.\n"
   12.33 -    "offset - offset of file system within file image.\n");
   12.34 +    "offset - offset of file system within file image.\n"
   12.35 +    "options - mount options string.\n");
   12.36  
   12.37  static struct PyMethodDef fsimage_module_methods[] = {
   12.38  	{ "open", (PyCFunction)fsimage_open,