void *sfs_init(struct fuse_conn_info *conn) { log_msg("Testing- log started- sfs_init()\n"); log_msg("\nsfs_init()\n"); log_conn(conn); log_fuse_context(fuse_get_context()); disk_open(SFS_DATA->diskfile); char *readbuf; char *writebuf; int status=block_read(0,&readbuf); struct super_block* sb; //writebuf=&sb; if(status==0){//first time in sfs_init sb = (struct super_block*)malloc(sizeof(struct super_block)); log_msg("Testing- first time in sfs_init\n"); sb->size=131072; sb->nblocks=256; sb->ninode=0; //log_msg("%d\n",sb.nblocks); writebuf=sb; int write_status=block_write(0,&writebuf); //log_msg("%d", write_status); if(write_status>0){ log_msg("Testing- write successful %d\n",write_status); struct super_block* testbuf; int x=block_read(0,&testbuf); log_msg("Read status %d\n",x); log_msg("Block read %d\n",testbuf->size); log_msg("Block read %d\n",testbuf->nblocks); log_msg("Block read %d\n",testbuf->ninode); } } disk_close(); //log_msg(hello_path); //char *test="abcd"; // char *test2; //int output=block_write(0,&test); //output = block_read(0, &test2); // log_msg("Block read :%s", test2); //log_msg(output); //disk_close(); log_msg("Testing- exiting sfs_init()\n"); return SFS_DATA; }
void *nphfuse_init(struct fuse_conn_info *conn){ log_msg("\nnphfuse_init()\n"); log_conn(conn); log_fuse_context(fuse_get_context()); log_msg("Into init function \n"); initialAllocationNPheap(); return NPHFS_DATA; }
// Undocumented but extraordinarily useful fact: the fuse_context is // set up before this function is called, and // fuse_get_context()->private_data returns the user_data passed to // fuse_main(). Really seems like either it should be a third // parameter coming in here, or else the fact should be documented // (and this might as well return void, as it did in older versions of // FUSE). void *bb_init(struct fuse_conn_info *conn) { log_msg("\nbb_init()\n"); log_conn(conn); log_fuse_context(fuse_get_context()); return BB_DATA; }
static void process_data_from_server() { /* enough data present for the length field ? */ if (3 <= in_data_used) { Uint8 *pData = in_data; Uint16 size; do { /* while (3 <= in_data_used) (enough data present for the length field) */ static const int foo = 1; /* used for run-time byteorder check */ /* make a copy of the length field...watch alignment/byteorder */ if (*(char *)&foo) { /* little-endian ? */ ((Uint8 *)&size)[0] = pData[1]; ((Uint8 *)&size)[1] = pData[2]; } else { /* big-endian */ ((Uint8 *)&size)[0] = pData[2]; ((Uint8 *)&size)[1] = pData[1]; } if (sizeof (in_data) - 3 >= size) { /* buffer big enough ? */ size += 2; /* add length field size */ if (size <= in_data_used) { /* do we have a complete message ? */ process_message_from_server(pData, size); if (log_conn_data) log_conn(pData, size); /* advance to next message */ pData += size; in_data_used -= size; } else break; } else { /* sizeof (in_data) - 3 < size */ log_to_console(c_red2, packet_overrun); log_to_console(c_red2, disconnected_from_server); log_to_console(c_red2, alt_x_quit); in_data_used = 0; disconnected = 1; // clear buddy list clear_buddy(); } } while (3 <= in_data_used); /* move the remaining data to the start of the buffer...(not tested...never happened to me) */ if (in_data_used && pData != in_data) memmove(in_data, pData, in_data_used); } }
void log_msg(const char *format, ...) { va_list ap; if (log_stream == NULL) return; log_timestamp(); log_conn(); va_start(ap, format); vfprintf(log_stream, format, ap); va_end(ap); putc('\n', log_stream); }
void log_error(const char *format, ...) { va_list ap; int error; if (log_stream == NULL) return; error = errno; log_timestamp(); log_conn(); va_start(ap, format); vfprintf(log_stream, format, ap); va_end(ap); fprintf(log_stream, ": %s", strerror(error)); putc('\n', log_stream); }