這是一個問題,我一直在爭取了很長一段時間,沒有任何進展。希望你能幫助我!使用FUSE列出目錄
我安裝FUSE在目錄( '家/ FSC')沒有問題,甚至列出它的父目錄(/家)方式如下:
而上/家.. ls -l命令
而getattr的操作工作得很好。當我打開目錄(「CD FSC」)發生
問題,正確打開,並調試操作,我可以看到保險絲詢問「/」文件屬性,但是當我嘗試列出該目錄中的文件,保險絲在無限循環中要求'/ tls'的屬性總是接收錯誤'2','沒有這樣的文件或目錄',直到它斷開連接。
我發現更令人好奇的是,它不會像我預期的那樣進入readdir操作。
任何想法爲什麼會發生這種情況?爲什麼保險絲要求'/ tls'屬性而不是執行'/'的readdir?
非常感謝您在這裏的幫助,我需要一個解決方案爲此大學項目我需要儘快工作,所以非常感謝幫助。
問候,
編輯:
我剛纔注意到,它也詢問 '/ i686的', '/ SSE2', '/ CMOV' 的文件attirbutes,「/librt.so。 1' 這個循環期間,然後又回到再次 '/ TLS'
2.-EDIT:
GETATTR OPERATION
int client_getattr(const char* c_ruta, struct stat* ptr_est_salida) {
int error = 0;
size_t size_structStat = sizeof(struct stat);
t_conexion* ptr_conexionLibre = poolConexion_obtenerConexion();
char out_key[50];
char s_stat[sizeof(struct stat)];
_ArmaKeyRC_fsc(c_ruta,GET_ATTR,out_key);
if (!strcmp((char*) configuracion_estadoRC(),"ON")){
if (rc_get_static(out_key, s_stat, &size_structStat) != 0) {
logger_info("Acierto en RC (Getattr) Se omite comunicacion con RFS...");
// TODO
return error;
} else {
logger_info("No hubo acierto en RC (Getattr) Inicia comunicacion con RFS...");
}
}
error = nipc_invocar_getattr(ptr_conexionLibre, c_ruta, ptr_est_salida);
if (!error){
logger_info("La operacion getattr fue realizada con éxito");
if (!strcmp((char*) configuracion_estadoRC(),"ON")){
logger_info("Almacenando getattr en RC...");
_serializaStructStat(*ptr_est_salida,s_stat);
rc_store(out_key, s_stat, sizeof(struct stat));
}
}
poolConexion_conexionDisponible(ptr_conexionLibre);
return error;
READDIR操作
int client_readdir(const char* c_ruta, void* ptr_salida,
fuse_fill_dir_t fn_llenadorDeElementosEnBuffer, off_t offset,
struct fuse_file_info* ptr_est_infoArchivo) {
int error = 0;
t_conexion* ptr_conexionLibre = poolConexion_obtenerConexion();
if (!strcmp((char*) configuracion_estadoRC(),"ON")){
if (rc_get(c_ruta) != 0) {
logger_info("Acierto en RC (Readdir) Se omite comunicacion con RFS...");
return error;
} else {
logger_info("No hubo acierto en RC (Readdir) Inicia comunicacion con RFS...");
}
}
char** ptr_datos=NULL;
size_t cantidadLeida = 0;
error = nipc_invocar_readDir(ptr_conexionLibre, c_ruta,
ptr_est_infoArchivo->fh, &ptr_datos, &cantidadLeida);
off_t filler_offset;
while (strcmp(ptr_datos[filler_offset],"")==0){
fn_llenadorDeElementosEnBuffer(ptr_salida,(const char*) ptr_datos[filler_offset],NULL,0);
filler_offset = filler_offset + 256;
}
if (!error){
logger_info("La operacion readdir fue realizada con éxito");
if (!strcmp((char*) configuracion_estadoRC(),"ON")){
logger_info("Almacenando readdir en RC...");
//char out_key[50];
//_ArmaKeyRC_fsc(c_ruta, GET_ATTR, out_key);
//rc_store(out_key, (char*) ptr_est_salida, sizeof(struct stat));
}
}
poolConexion_conexionDisponible(ptr_conexionLibre);
return error;
FUSE主要
#include "fuse_interface.h"
#include <stddef.h>
#include <stdlib.h>
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include "cliente.h"
// Estructura auxiliar que se usa para pasarle parámetros
// por línea de comando a la función principal de FUSE
struct t_runtime_options {
char* welcome_msg;
} runtime_options;
// Esta macro sirve para definir nuestros propios parámetros
#define CUSTOM_FUSE_OPT_KEY(t, p, v) { t, offsetof(struct t_runtime_options, p), v }
// Estructura de operaciones de FUSE, contiene
// punteros a las funciones que debe ejecutar FUSE
// según se solicite.
static struct fuse_operations client_operations = { .getattr = client_getattr,
.readdir = client_readdir, .open = client_open, .read = client_read,
.unlink = client_unlink, .release = client_release, .rmdir =
client_rmdir, .truncate = client_truncate,
.write = client_write, .create = client_create, .mkdir = client_mkdir, };
/** keys for FUSE_OPT_ options */
enum {
KEY_VERSION, KEY_HELP,
};
//Esta estructura es utilizada para decirle a la biblioteca de FUSE que
// parametro puede recibir y donde tiene que guardar el valor de estos
static struct fuse_opt fuse_options[] = {
// Este es un parámetro definido por la cátedra de SISOP
CUSTOM_FUSE_OPT_KEY("--welcome-msg %s", welcome_msg, 0),
// Estos son parametros por defecto que ya tiene FUSE
FUSE_OPT_KEY("-V", KEY_VERSION), FUSE_OPT_KEY("--version", KEY_VERSION),
FUSE_OPT_KEY("-h", KEY_HELP), FUSE_OPT_KEY("--help", KEY_HELP),
FUSE_OPT_END, };
int main(int argc, char *argv[]) {
if (argc < 2) {
perror("FSC:falta indicar la ruta del archivo de configuracion");
exit(-1);
}
char c_config[256];
strcpy(c_config, argv[1]);
cliente_iniciar(c_config);
int fuse_argc = 3;
char nombrePrograma[256];
strcpy(nombrePrograma, argv[0]);
char puntoMontaje[256];
strcpy(puntoMontaje, configuracion_pathMontajeFS());
char parametro[256];
strcpy(parametro, "-f");
char* fuse_argv[3];
fuse_argv[0]=nombrePrograma;
fuse_argv[1]=puntoMontaje;
fuse_argv[2]=parametro;
printf("Iniciando Fuse: Mount Point: %s", configuracion_pathMontajeFS());
// Inicializo la estructura de argumentos de FUSE
struct fuse_args args = FUSE_ARGS_INIT(fuse_argc, fuse_argv);
// Limpio la estructura que va a contener los parametros
memset(&runtime_options, 0, sizeof(struct t_runtime_options));
// Esta funcion de FUSE lee los parametros recibidos y los intepreta
if (fuse_opt_parse(&args, &runtime_options, fuse_options, NULL) == -1) {
perror("Fuse dice: Argumentos Invalidos");
return EXIT_FAILURE;
}
// Si se paso el parametro --welcome-msg
// el campo welcome_msg deberia tener el
// valor pasado
if (runtime_options.welcome_msg != NULL) {
printf("%s\n", runtime_options.welcome_msg);
} else {
}
// Esta es la funcion principal de FUSE, es la que se encarga
// de realizar el montaje, comuniscarse con el kernel, delegar las cosas
// en varios threads
return fuse_main(args.argc, args.argv, &client_operations, NULL);
}
你需要包含你的代碼,以便我們能夠理解你在說什麼。我們所能做的只是猜測你的問題是什麼。 – 2012-07-16 00:01:21
@JeffMercado:謝謝你的回答,我明白你的意思,我沒有,因爲代碼非常龐大,請檢查我的帖子,我將添加即時通訊的getattr和readdir操作。 – 2012-07-16 00:04:25
@JeffMercado:無論如何,如果您可以告訴我FUSE在嘗試列出掛載點時的行爲方式,它可以幫助我很多!這更多是一個概念上的疑問。 – 2012-07-16 00:10:32