Annotation of qemu/fsdev/qemu-fsdev.c, revision 1.1.1.4

1.1       root        1: /*
                      2:  * Virtio 9p
                      3:  *
                      4:  * Copyright IBM, Corp. 2010
                      5:  *
                      6:  * Authors:
                      7:  *  Gautham R Shenoy <[email protected]>
                      8:  *
                      9:  * This work is licensed under the terms of the GNU GPL, version 2.  See
                     10:  * the COPYING file in the top-level directory.
                     11:  *
                     12:  */
                     13: #include <stdio.h>
                     14: #include <string.h>
                     15: #include "qemu-fsdev.h"
                     16: #include "qemu-queue.h"
                     17: #include "osdep.h"
                     18: #include "qemu-common.h"
1.1.1.2   root       19: #include "qemu-config.h"
1.1       root       20: 
1.1.1.3   root       21: static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =
                     22:     QTAILQ_HEAD_INITIALIZER(fsdriver_entries);
1.1       root       23: 
1.1.1.3   root       24: static FsDriverTable FsDrivers[] = {
1.1       root       25:     { .name = "local", .ops = &local_ops},
1.1.1.3   root       26: #ifdef CONFIG_OPEN_BY_HANDLE
                     27:     { .name = "handle", .ops = &handle_ops},
                     28: #endif
                     29:     { .name = "synth", .ops = &synth_ops},
1.1.1.4 ! root       30:     { .name = "proxy", .ops = &proxy_ops},
1.1       root       31: };
                     32: 
                     33: int qemu_fsdev_add(QemuOpts *opts)
                     34: {
                     35:     int i;
1.1.1.4 ! root       36:     struct FsDriverListEntry *fsle;
1.1.1.2   root       37:     const char *fsdev_id = qemu_opts_id(opts);
1.1.1.3   root       38:     const char *fsdriver = qemu_opt_get(opts, "fsdriver");
                     39:     const char *writeout = qemu_opt_get(opts, "writeout");
                     40:     bool ro = qemu_opt_get_bool(opts, "readonly", 0);
1.1       root       41: 
1.1.1.2   root       42:     if (!fsdev_id) {
1.1       root       43:         fprintf(stderr, "fsdev: No id specified\n");
                     44:         return -1;
                     45:     }
                     46: 
1.1.1.3   root       47:     if (fsdriver) {
                     48:         for (i = 0; i < ARRAY_SIZE(FsDrivers); i++) {
                     49:             if (strcmp(FsDrivers[i].name, fsdriver) == 0) {
1.1.1.2   root       50:                 break;
                     51:             }
1.1       root       52:         }
                     53: 
1.1.1.3   root       54:         if (i == ARRAY_SIZE(FsDrivers)) {
                     55:             fprintf(stderr, "fsdev: fsdriver %s not found\n", fsdriver);
1.1.1.2   root       56:             return -1;
                     57:         }
                     58:     } else {
1.1.1.3   root       59:         fprintf(stderr, "fsdev: No fsdriver specified\n");
1.1       root       60:         return -1;
                     61:     }
                     62: 
1.1.1.4 ! root       63:     fsle = g_malloc0(sizeof(*fsle));
1.1.1.3   root       64:     fsle->fse.fsdev_id = g_strdup(fsdev_id);
                     65:     fsle->fse.ops = FsDrivers[i].ops;
                     66:     if (writeout) {
                     67:         if (!strcmp(writeout, "immediate")) {
                     68:             fsle->fse.export_flags |= V9FS_IMMEDIATE_WRITEOUT;
                     69:         }
                     70:     }
                     71:     if (ro) {
                     72:         fsle->fse.export_flags |= V9FS_RDONLY;
                     73:     } else {
                     74:         fsle->fse.export_flags &= ~V9FS_RDONLY;
                     75:     }
1.1       root       76: 
1.1.1.4 ! root       77:     if (fsle->fse.ops->parse_opts) {
        !            78:         if (fsle->fse.ops->parse_opts(opts, &fsle->fse)) {
        !            79:             return -1;
        !            80:         }
1.1.1.3   root       81:     }
1.1       root       82: 
1.1.1.3   root       83:     QTAILQ_INSERT_TAIL(&fsdriver_entries, fsle, next);
                     84:     return 0;
1.1       root       85: }
                     86: 
1.1.1.3   root       87: FsDriverEntry *get_fsdev_fsentry(char *id)
1.1       root       88: {
1.1.1.2   root       89:     if (id) {
1.1.1.3   root       90:         struct FsDriverListEntry *fsle;
1.1       root       91: 
1.1.1.3   root       92:         QTAILQ_FOREACH(fsle, &fsdriver_entries, next) {
1.1.1.2   root       93:             if (strcmp(fsle->fse.fsdev_id, id) == 0) {
                     94:                 return &fsle->fse;
                     95:             }
1.1       root       96:         }
                     97:     }
                     98:     return NULL;
                     99: }
1.1.1.2   root      100: 
                    101: static void fsdev_register_config(void)
                    102: {
                    103:     qemu_add_opts(&qemu_fsdev_opts);
                    104:     qemu_add_opts(&qemu_virtfs_opts);
                    105: }
                    106: machine_init(fsdev_register_config);
                    107: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.