コード例 #1
0
int
main (int argc, char *argv[])
{
    int        ret      = 0;
    glfs_t    *fs       = NULL;
    char       buf[100];
    glfs_fd_t *fd       = NULL;

    if (argc != 4) {
        fprintf (stderr,
                 "Expect following args %s <hostname> <Vol> <log file location>\n"
                 , argv[0]);
        return -1;
    }

    fs = setup_new_client (argv[1], argv[2], argv[3]);
    if (!fs)
        goto error;

    ret = volfile_change (argv[2]);
    if (ret < 0)
        goto error;

    /* This is required as volfile change takes a while to reach this
     * gfapi client and precess the graph change. Without this the issue
     * cannot be reproduced as in cannot be tested.
     */
    sleep (10);

    ret = write_something (fs);
    if (ret < 0)
        goto error;

    ret = glfs_fini (fs);
    if (ret < 0) {
        fprintf (stderr, "glfs_fini failed with ret: %d (%s)\n",
                 ret, strerror (errno));
        goto error;
    }

    return 0;
error:
    return -1;
}
コード例 #2
0
ファイル: bug-1093594.c プロジェクト: 2510/glusterfs
int
main (int argc, char *argv[])
{
        glfs_t    *fs       = NULL;
        int       ret       = 0;
        int       i         = 0;
        glfs_fd_t *fd       = NULL;
        glfs_fd_t *fd1      = NULL;
        char      *topdir   = "topdir", *filename = "file1";
        char      *buf      = NULL;
        char      *logfile  = NULL;

        if (argc != 3) {
                fprintf (stderr,
                        "Expect following args %s <Vol> <log file>\n"
                        , argv[0]);
                return -1;
        }

        logfile = argv[2];

        for (i = 0; i < TEST_CASE_LOOP; i++) {
                fs = glfs_new (argv[1]);
                if (!fs) {
                        fprintf (stderr, "glfs_new: returned NULL (%s)\n",
                                strerror (errno));
                        return -1;
                }

                ret = glfs_set_volfile_server (fs, "tcp", "localhost", 24007);
                if (ret < 0) {
                        fprintf (stderr, "glfs_set_volfile_server failed ret:%d (%s)\n",
                        ret, strerror (errno));
                        return -1;
                }

                ret = glfs_set_logging (fs, logfile, 7);
                if (ret < 0) {
                        fprintf (stderr, "glfs_set_logging failed with ret: %d (%s)\n",
                                ret, strerror (errno));
                        return -1;
                }

                ret = glfs_init (fs);
                if (ret < 0) {
                        fprintf (stderr, "glfs_init failed with ret: %d (%s)\n",
                                ret, strerror (errno));
                        return -1;
                }

                ret = large_number_of_fops (fs);
                if (ret < 0)
                        return -1;

                ret = large_read_write (fs);
                if (ret < 0)
                        return -1;

                ret = volfile_change (argv[1]);
                if (ret < 0)
                        return -1;

                ret = large_number_of_fops (fs);
                if (ret < 0)
                        return -1;

                ret = large_read_write (fs);
                if (ret < 0)
                        return -1;

                ret = glfs_fini (fs);
                if (ret < 0) {
                        fprintf (stderr, "glfs_fini failed with ret: %d (%s)\n",
                                ret, strerror (errno));
                        return -1;
                }
        }
        return 0;
}