示例#1
0
/*
 * Instead of just calling gfs_pio_set_view_index(),
 * we use another GFS_File to move to another fragment.
 * This is because we don't want to leave this context inconsistent,
 * if failure happens at the gfs_pio_set_view_index().
 */
static char *
gfs_pio_view_global_move_to(GFS_File gf, int fragment_index)
{
	struct gfs_file_global_context *gc = gf->view_context;
	char *e;
	GFS_File new_fragment;

	if ((gf->open_flags & GFARM_FILE_CREATE) != 0)
		e = gfs_pio_create(gc->url, gf->open_flags,
		    gf->pi.status.st_mode & GFARM_S_ALLPERM,
		    &new_fragment);
	else
		e = gfs_pio_open(gc->url, gf->open_flags, &new_fragment);
	if (e != NULL)
		return (e);
	e = gfs_pio_set_view_index(new_fragment, gf->pi.status.st_nsections,
	    fragment_index, NULL, gf->view_flags);
	if (e != NULL) {
		gfs_pio_close(new_fragment);
		return (e);
	}
	if (gc->fragment_gf != NULL) {
		gfs_pio_close(gc->fragment_gf);
		/* XXX need a way to report error on here */
	}
	gc->fragment_gf = new_fragment;
	gc->fragment_index = fragment_index;
	return (NULL);
}
示例#2
0
static gfarm_error_t
gfs_replicate_to_internal(char *file, char *dsthost, int dstport, int migrate)
{
	char *srchost;
	int srcport;
	gfarm_error_t e, e2;
	GFS_File gf;

	e = gfs_pio_open(file, GFARM_FILE_RDONLY, &gf);
	if (e != GFARM_ERR_NO_ERROR) {
		gflog_debug(GFARM_MSG_1001389,
			"gfs_pio_open(%s) failed: %s",
			file,
			gfarm_error_string(e));
		return (e);
	}

	e = gfarm_schedule_file(gf, &srchost, &srcport);
	if (e == GFARM_ERR_NO_ERROR) {

#ifndef V2_4
		e = gfs_replicate_from_to_internal(gf, srchost, srcport,
			dsthost, dstport);
#else
		e = gfs_replicate_file_from_to(file, srchost, dsthost,
		    GFS_REPLICATE_FILE_FORCE
		    /* | GFS_REPLICATE_FILE_WAIT */ /* XXX NOTYET */);
#endif
		if (e == GFARM_ERR_NO_ERROR && migrate)
			e = gfs_replica_remove_by_file(file, srchost);
		free(srchost);
	}
	e2 = gfs_pio_close(gf);

	if (e != GFARM_ERR_NO_ERROR || e2 != GFARM_ERR_NO_ERROR) {
		gflog_debug(GFARM_MSG_1001390,
			"error occurred in gfs_replicate_to_internal(): %s",
			gfarm_error_string(e != GFARM_ERR_NO_ERROR ? e : e2));
	}

	return (e != GFARM_ERR_NO_ERROR ? e : e2);
}
示例#3
0
gfarm_error_t
gfs_replicate_from_to(char *file, char *srchost, int srcport,
	char *dsthost, int dstport)
{
#ifndef V2_4
	gfarm_error_t e, e2;
	GFS_File gf;

	if (srchost == NULL)
		return (gfs_replicate_to(file, dsthost, dstport));

	e = gfs_pio_open(file, GFARM_FILE_RDONLY, &gf);
	if (e != GFARM_ERR_NO_ERROR) {
		gflog_debug(GFARM_MSG_1001392,
			"gfs_pio_open(%s) failed: %s",
			file,
			gfarm_error_string(e));
		return (e);
	}

	e = gfs_replicate_from_to_internal(gf, srchost, srcport,
		dsthost, dstport);
	e2 = gfs_pio_close(gf);

	if (e != GFARM_ERR_NO_ERROR || e2 != GFARM_ERR_NO_ERROR) {
		gflog_debug(GFARM_MSG_1001393,
			"replication failed (%s) from (%s:%d) to (%s:%d): %s",
			file, srchost, srcport, dsthost, dstport,
			gfarm_error_string(e != GFARM_ERR_NO_ERROR ? e : e2));
	}

	return (e != GFARM_ERR_NO_ERROR ? e : e2);
#else
	return (gfs_replicate_file_from_to(file, srchost, dsthost,
	    GFS_REPLICATE_FILE_FORCE
	    /* | GFS_REPLICATE_FILE_WAIT */ /* XXX NOTYET */));

#endif
}
示例#4
0
gfarm_error_t
gfs_replicate_file_to_request(
	const char *file, const char *dsthost, int flags)
{
	char *srchost;
	int srcport;
	gfarm_error_t e, e2;
	GFS_File gf;

	e = gfs_pio_open(file, GFARM_FILE_RDONLY, &gf);
	if (e != GFARM_ERR_NO_ERROR)
		return (e);

	e = gfarm_schedule_file(gf, &srchost, &srcport);
	e2 = gfs_pio_close(gf);
	if (e == GFARM_ERR_NO_ERROR) {
		e = gfs_replicate_file_from_to_request(file, srchost,
		    dsthost, flags);
		free(srchost);
	}

	return (e != GFARM_ERR_NO_ERROR ? e : e2);
}
示例#5
0
int webgfarm_api_v1_write_to_file(request_rec *r) {

    // get filepath from request
    char *filepath = webgfarm_api_v1_getfilepath(r);

    if (filepath == NULL || strlen(filepath) == 0) {
        return HTTP_FORBIDDEN;
    }

    gfarm_error_t gerr;
    GFS_File gfs_file;


    webgfarm_config *wconfig = ap_get_module_config(r->server->module_config, &webgfarm_module);
    if (wconfig->write_redirect) {

        char *redirect_url = apr_palloc(r->pool, sizeof (char)*WEBGFARM_BUFFER_SIZE);
        const char *port;

        int available_nhosts;
        struct gfarm_host_sched_info *available_hosts;
        gerr = gfarm_schedule_hosts_domain_by_file(filepath, GFARM_FILE_RDONLY, "", &available_nhosts, &available_hosts);

        if (available_nhosts > 0) {
            if (gerr == GFARM_ERR_NO_ERROR) {
                int *ports;
                char **hosts;
                int nhosts = available_nhosts;
                int i;
                GFARM_MALLOC_ARRAY(hosts, available_nhosts);
                GFARM_MALLOC_ARRAY(ports, available_nhosts);
                gerr = gfarm_schedule_hosts_acyclic_to_write(filepath, available_nhosts, available_hosts, &nhosts, hosts, ports);

                if (nhosts > 0 && gerr == GFARM_ERR_NO_ERROR) {
                    for (i = 0; i < nhosts; i++) {
                        port = apr_table_get(wconfig->hosts, hosts[i]);
                        if (port != NULL) {
                            if (strcmp(wconfig->localhost, hosts[i]) != 0) {
                                if (wconfig->ssl) {
                                    snprintf(redirect_url, WEBGFARM_BUFFER_SIZE, "https://%s:%s%s", hosts[i], port, r->uri);
                                } else {
                                    snprintf(redirect_url, WEBGFARM_BUFFER_SIZE, "http://%s:%s%s", hosts[i], port, r->uri);
                                }
                                apr_table_set(r->headers_out, "Location", redirect_url);
                                free(ports);
                                free(hosts);
                                return HTTP_TEMPORARY_REDIRECT;
                            } else {
                                break;
                            }
                        }
                    }
                }

                free(ports);
                free(hosts);
            } else if (gerr != GFARM_ERR_NO_SUCH_FILE_OR_DIRECTORY) {
                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "gfarm_schedule_hosts_domain_by_file can not get the hosts of the file(%s) with error: %s", filepath, gfarm_error_string(gerr));
                return HTTP_INTERNAL_SERVER_ERROR;
            }
        }
    }

    // open
    if (r->method_number == M_POST) {
        gerr = gfs_pio_open(filepath, GFARM_FILE_WRONLY | GFARM_FILE_APPEND, &gfs_file);
    } else if (r->method_number == M_PUT) {
        gerr = gfs_pio_open(filepath, GFARM_FILE_WRONLY | GFARM_FILE_TRUNC, &gfs_file);
        if (gerr == GFARM_ERR_NO_SUCH_FILE_OR_DIRECTORY) {
            gerr = gfs_pio_create(filepath, GFARM_FILE_WRONLY, 0644, &gfs_file);
        }
    } else {
        return HTTP_INTERNAL_SERVER_ERROR;
    }

    if (gerr != GFARM_ERR_NO_ERROR) {
        switch (gerr) {
            case GFARM_ERR_NO_SUCH_FILE_OR_DIRECTORY:
                return HTTP_NOT_FOUND;
                break;
            case GFARM_ERR_PERMISSION_DENIED:
                return HTTP_FORBIDDEN;
                break;
                //FIXEME: Support more error;
            default:
                return HTTP_INTERNAL_SERVER_ERROR;
        }
    }

    // get input body size;
    int in_size;
    const char *clen = apr_table_get(r->headers_in, "Content-Length");
    if (clen != NULL) {
        in_size = strtol(clen, NULL, 0);
        if (in_size >= WEBGFFARM_MAX_POST_SIZE) {
            gfs_pio_close(gfs_file);
            return HTTP_BAD_REQUEST;
        }
    } else {
        gfs_pio_close(gfs_file);
        return HTTP_BAD_REQUEST;
    }

    if (in_size != 0) {
        apr_off_t size = 0;
        char *buf;

        if (util_read(r, &buf, &size) != OK) {
            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[write] failed reading POST body");
            gfs_pio_close(gfs_file);
            return HTTP_INTERNAL_SERVER_ERROR;
        }

        in_size = (int) size;

        if (buf == NULL) {
            return HTTP_BAD_REQUEST;
        }

        // write buffer
        int write_size;
        gerr = gfs_pio_write(gfs_file, buf, in_size, &write_size);
        if (gerr != GFARM_ERR_NO_ERROR) {
            if (in_size != write_size) {
                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[write] gfs_pio_write failure..(in: %d, out: %d)", (int) in_size, (int) write_size);
            }
            gerr = gfs_pio_close(gfs_file);
            return HTTP_INTERNAL_SERVER_ERROR;
        }
    }

    // close
    gerr = gfs_pio_close(gfs_file);
    if (gerr != GFARM_ERR_NO_ERROR) {
        return HTTP_INTERNAL_SERVER_ERROR;
    } else {
        return OK;
    }

}
示例#6
0
int webgfarm_api_v1_read_file(request_rec *r) {
    // get filepath from request
    char *filepath = webgfarm_api_v1_getfilepath(r);

    if (filepath == NULL || strlen(filepath) == 0) {
        return HTTP_FORBIDDEN;
    }

    webgfarm_config *wconfig = ap_get_module_config(r->server->module_config, &webgfarm_module);

    gfarm_error_t gerr;
    GFS_File gfs_file;

    if (wconfig->read_redirect) {
        //        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[read] read_redirect is on.");

        char *redirect_url = apr_palloc(r->pool, sizeof (char)*WEBGFARM_BUFFER_SIZE);

        const char *port;

        int available_nhosts;
        struct gfarm_host_sched_info *available_hosts;
        gerr = gfarm_schedule_hosts_domain_by_file(filepath, GFARM_FILE_RDONLY, "", &available_nhosts, &available_hosts);
        if (gerr == GFARM_ERR_NO_ERROR) {
            //            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[read] gfarm_schedule_hosts_domain_by_file() has no error.");
            int *ports;
            char **hosts;
            int nhosts = available_nhosts;
            int i;
            GFARM_MALLOC_ARRAY(hosts, available_nhosts);
            GFARM_MALLOC_ARRAY(ports, available_nhosts);
            gerr = gfarm_schedule_hosts_acyclic(filepath, available_nhosts, available_hosts, &nhosts, hosts, ports);

            if (nhosts > 0 && gerr == GFARM_ERR_NO_ERROR) {
                //                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[read] gfarm_schedule_hosts_acyclic() has no error.");
                for (i = 0; i < nhosts; i++) {
                    port = apr_table_get(wconfig->hosts, hosts[i]);
                    if (port != NULL) {
                        if (strcmp(wconfig->localhost, hosts[i]) != 0) {
                            if (wconfig->ssl) {
                                snprintf(redirect_url, WEBGFARM_BUFFER_SIZE, "https://%s:%s%s", hosts[i], port, r->uri);
                            } else {
                                snprintf(redirect_url, WEBGFARM_BUFFER_SIZE, "http://%s:%s%s", hosts[i], port, r->uri);
                            }
                            apr_table_set(r->headers_out, "Location", redirect_url);
                            free(ports);
                            free(hosts);
                            return HTTP_TEMPORARY_REDIRECT;
                        } else {
                            break;
                        }
                    }
                }
            }

            free(ports);
            free(hosts);
        } else if (gerr != GFARM_ERR_NO_SUCH_FILE_OR_DIRECTORY) {
            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "gfarm_schedule_hosts_domain_by_file can not get the hosts of the file(%s) with error: %s", filepath, gfarm_error_string(gerr));
            return HTTP_INTERNAL_SERVER_ERROR;
        }
    }

    // open
    gerr = gfs_pio_open(filepath, GFARM_FILE_RDONLY, &gfs_file);
    if (gerr != GFARM_ERR_NO_ERROR) {
        switch (gerr) {
            case GFARM_ERR_NO_SUCH_FILE_OR_DIRECTORY:
                return HTTP_NOT_FOUND;
                break;
            case GFARM_ERR_PERMISSION_DENIED:
                return HTTP_FORBIDDEN;
                break;
                //FIXEME: Support more error;
            default:
                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "gfs_pio_open can not open the file(%s) with error: %s", filepath, gfarm_error_string(gerr));
                return HTTP_INTERNAL_SERVER_ERROR;
        }
    }

    // get stat
    struct gfs_stat gs;
    gerr = gfs_pio_stat(gfs_file, &gs);
    if (gerr != GFARM_ERR_NO_ERROR) {
        gfs_pio_close(gfs_file);
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "gfs_pio_stat can not get the stat of the file(%s) with error: %s", filepath, gfarm_error_string(gerr));
        return HTTP_INTERNAL_SERVER_ERROR;
    }
    char *stat_buffer = apr_palloc(r->pool, sizeof (char)*WEBGFARM_BUFFER_SIZE);
    snprintf(stat_buffer, WEBGFARM_BUFFER_SIZE, "%lu", gs.st_ino);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-INO", stat_buffer);
    snprintf(stat_buffer, WEBGFARM_BUFFER_SIZE, "%lu", gs.st_gen);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-GEN", stat_buffer);
    snprintf(stat_buffer, WEBGFARM_BUFFER_SIZE, "%o", gs.st_mode);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-MODE", stat_buffer);
    snprintf(stat_buffer, WEBGFARM_BUFFER_SIZE, "%lu", gs.st_nlink);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-NLINK", stat_buffer);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-USER", gs.st_user);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-GROUP", gs.st_group);
    snprintf(stat_buffer, WEBGFARM_BUFFER_SIZE, "%lu", gs.st_size);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-SIZE", stat_buffer);
    snprintf(stat_buffer, WEBGFARM_BUFFER_SIZE, "%lu", gs.st_ncopy);
    apr_table_set(r->headers_out, "X-WEBGFARM-STAT-NCOPY", stat_buffer);

    //    gerr == GFARM_ERR_NO_ERROR
    //read and puts
    if (!r->header_only) {
        char *buf = apr_palloc(r->pool, sizeof (char)*WEBGFARM_BUFFER_SIZE);
        int read_size = 0;
        do {
            gerr = gfs_pio_read(gfs_file, buf, WEBGFARM_BUFFER_SIZE, &read_size);
            if (gerr != GFARM_ERR_NO_ERROR) {
                gerr = gfs_pio_close(gfs_file);
                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "gfs_pio_read can not read the file(%s) with error: %s", filepath, gfarm_error_string(gerr));
                return HTTP_INTERNAL_SERVER_ERROR;
            } else {
                if (read_size != 0) {
                    ap_rwrite(buf, read_size, r);
                }
            }
        } while (gerr == GFARM_ERR_NO_ERROR && read_size != 0);
    }

    // close
    gerr = gfs_pio_close(gfs_file);
    if (gerr != GFARM_ERR_NO_ERROR) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "gfs_pio_close can not close the file(%s) with error: %s", filepath, gfarm_error_string(gerr));

        return HTTP_INTERNAL_SERVER_ERROR;
    } else {
        return OK;
    }
}
示例#7
0
文件: gfsck.c 项目: krichter722/gfarm
static char *
gfsck_file(char *gfarm_url)
{
	char *gfarm_file, *e, *e_save = NULL;
	int i, nsections, valid_nsections = 0;
	struct gfarm_file_section_info *sections;
	GFS_File gf;

	e = gfarm_url_make_path(gfarm_url, &gfarm_file);
	if (e != NULL)
		return (e);

	e = gfarm_file_section_info_get_all_by_file(
		gfarm_file, &nsections, &sections);
	if (e != NULL) {
		/* no section info, remove path info */
		e = path_info_remove(gfarm_url, gfarm_file);
		free(gfarm_file);
		return (e);
	}

	e = gfs_pio_open(gfarm_url, GFARM_FILE_RDONLY, &gf);
	if (e != NULL) {
		free(gfarm_file);
		return (e);
	}

	for (i = 0; i < nsections; i++) {
		int j, ncopies, valid_ncopies = 0;
		struct gfarm_file_section_copy_info *copies;
		char *section = sections[i].section;

		e = gfarm_file_section_copy_info_get_all_by_section(
			gfarm_file, section, &ncopies, &copies);
		if (e == GFARM_ERR_NO_SUCH_OBJECT) {
			/* no section copy info, remove section info */
			e = section_info_remove(gfarm_url, gfarm_file, section);
			if (e != NULL && e_save == NULL)
				e_save = e;
			continue;
		}
		else if (e != NULL) {
			fprintf(stderr, "%s (%s): %s\n",
				gfarm_url, section, e);
			if (e_save == NULL)
				e_save = e;
			continue;
		}
		for (j = 0; j < ncopies; ++j) {
			if (option_verbose)
				printf("%s (%s) on %s\n", gfarm_url, section,
				       copies[j].hostname);
			e = gfs_pio_set_view_section(gf, section,
			    copies[j].hostname,
			    GFARM_FILE_NOT_REPLICATE | GFARM_FILE_NOT_RETRY);
			if (e == GFARM_ERR_INCONSISTENT_RECOVERABLE) {
				/* invalid section copy info removed */
				printf("%s (%s) on %s: "
				       "invalid metadata deleted\n",
				       gfarm_url, section,
				       copies[j].hostname);
				e = NULL;
			}
			else {
				++valid_ncopies;
				if (e != NULL) {
					fprintf(stderr, "%s (%s) on %s: %s\n",
						gfarm_url, section,
						copies[j].hostname, e);
					if (e_save == NULL)
						e_save = e;
				}
			}

		}
		gfarm_file_section_copy_info_free_all(ncopies, copies);
		if (valid_ncopies == 0) {
			/* no section copy info, remove section info */
			e = section_info_remove(gfarm_url, gfarm_file, section);
			if (e != NULL && e_save == NULL)
				e_save = e;
		}
		else
			++valid_nsections;
	}
	if (valid_nsections == 0) {
		/* no section info, remove path info */
		e = path_info_remove(gfarm_url, gfarm_file);
		if (e != NULL && e_save == NULL)
			e_save = e;
	}
	else if (valid_nsections < nsections) {
		printf("%s: warning: number of file sections reduced\n",
		       gfarm_url);
	}

	gfarm_file_section_info_free_all(nsections, sections);
	free(gfarm_file);

	e = gfs_pio_close(gf);
	if (e != NULL)
		return (e);

	return (e_save);
}
示例#8
0
int
FUNC___OPEN(const char *path, int oflag, ...)
{
	GFS_File gf;
	const char *e;
	char *url, *sec;
	va_list ap;
	mode_t mode;
	int filedes;

	va_start(ap, oflag);
	mode = va_arg(ap, mode_t);
	va_end(ap);

	_gfs_hook_debug_v(fprintf(stderr,
	    "Hooking " S(FUNC___OPEN) "(%s, 0x%x)\n", path, oflag));

	if (!gfs_hook_is_url(path, &url, &sec))
		return (SYSCALL_OPEN(path, oflag, mode));

	/* XXX - ROOT I/O creates a new file with O_CREAT|O_RDWR mode. */
	/* XXX - FIXME */
	if ((oflag & O_CREAT) != 0 || (oflag & O_TRUNC) != 0) {
		_gfs_hook_debug(fprintf(stderr,
		    "GFS: Hooking " S(FUNC___OPEN) "(%s:%s, 0x%x, 0%o)\n",
		    url, sec != NULL ? sec : "(null)", oflag, mode));
		if (oflag & O_TRUNC) {
			/*
			 * Hooking open syscall does not mean to open
			 * an entire file but a file fragment in local and
			 * index file views.  gfs_unlink() should not be
			 * called in both views.
			 */
			if (_gfs_hook_default_view == global_view)
				gfs_unlink(url); /* XXX - FIXME */
			e = gfs_pio_create(url, oflag, mode, &gf);
		} else {
			e = gfs_pio_open(url, oflag, &gf);
			if (e == GFARM_ERR_NO_SUCH_OBJECT) /* XXX - FIXME */
				e = gfs_pio_create(url, oflag, mode, &gf);
		}
	} else {
		_gfs_hook_debug(fprintf(stderr,
		    "GFS: Hooking " S(FUNC___OPEN) "(%s:%s, 0x%x)\n",
		    url, sec != NULL ? sec : "(null)", oflag));
		e = gfs_pio_open(url, oflag, &gf);
	}
	free(url);
	if (e != NULL) {
		_gfs_hook_debug(fprintf(stderr,
		    "GFS: Hooking " S(FUNC___OPEN) ": %s\n", e));
		errno = gfarm_error_to_errno(e);
		return (-1);
	}

	if (sec != NULL || _gfs_hook_default_view == index_view) {
		if (sec != NULL) {
			_gfs_hook_debug(fprintf(stderr,
				"GFS: set_view_section(%s, %s)\n", url, sec));
			e = gfs_pio_set_view_section(gf, sec, NULL, 0);
			free(sec);
		} else {
			_gfs_hook_debug(fprintf(stderr,
				"GFS: set_view_index(%s, %d, %d)\n", url,
				_gfs_hook_num_fragments, _gfs_hook_index));
			e = gfs_pio_set_view_index(gf, _gfs_hook_num_fragments,
				_gfs_hook_index, NULL, 0);
		}
		if (e != NULL) {
			_gfs_hook_debug(fprintf(stderr,
			    "GFS: set_view_section: %s\n", e));
			gfs_pio_close(gf);
			errno = gfarm_error_to_errno(e);
			return (-1);
		}
	} else if (_gfs_hook_default_view == local_view) {
		int nf = -1, np;
		/*
		 * If the number of fragments is not the same as the
		 * number of parallel processes, or the file is not
		 * fragmented, do not change to the local file view.
		 */
		if (gfs_pio_get_nfragment(gf, &nf) ==
			GFARM_ERR_FRAGMENT_INDEX_NOT_AVAILABLE ||
		    (gfs_pio_get_node_size(&np) == NULL && nf == np)) {
			_gfs_hook_debug(fprintf(stderr,
				"GFS: set_view_local(%s (%d, %d))\n",
					url, gfarm_node, gfarm_nnode));
			if ((e = gfs_pio_set_view_local(gf, 0)) != NULL) {
				_gfs_hook_debug(fprintf(stderr,
					"GFS: set_view_local: %s\n", e));
				gfs_pio_close(gf);
				errno = gfarm_error_to_errno(e);
				return (-1);
			}
		}
	}
	filedes = gfs_hook_insert_gfs_file(gf);
	_gfs_hook_debug(
		if (filedes != -1) {
			fprintf(stderr,
			    "GFS: Hooking " S(FUNC___OPEN) " --> %d(%d)\n",
			    filedes, gfs_pio_fileno(gf));
		}
	);