/* * FUSE calls its equivalent of stat(2) "getattr". This just gets stat * information, e.g. file size and permissions. */ static int brp_getattr(const char *in_path, struct stat *stbuf) { SET_CALLER_UID(); struct out_item *out_item; struct in_item *in_item; char *tail; char *config_str; int ret, fd; int stratum_id; if (in_path[0] == '/' && in_path[1] == '\0') { memcpy(stbuf, &parent_stat, sizeof(parent_stat)); return 0; } if (strcmp(in_path, "/reparse_config") == 0) { memcpy(stbuf, &reparse_stat, sizeof(reparse_stat)); config_str = config_contents(); if (config_str) { stbuf->st_size = strlen(config_str); free(config_str); return 0; } else { return -ENOMEM; } } if ( (ret = corresponding((char*)in_path, &fd, stbuf, &out_item, &stratum_id, &in_item, &tail)) >= 0) { stat_filter(stbuf, fd, out_item->filter, stratum_id, in_item, tail); return 0; } else { return ret; } }
/* * Check for presence of boot catalog. If it does not exist then make it */ void FDECL1(init_boot_catalog, const char *, path) { int bcat; char * bootpath; /* filename of boot catalog */ char * buf; struct stat statbuf; bootpath = (char *) e_malloc(strlen(boot_catalog)+strlen(path)+2); strcpy(bootpath, path); if (bootpath[strlen(bootpath)-1] != '/') { strcat(bootpath,"/"); } strcat(bootpath, boot_catalog); /* * check for the file existing */ #ifdef DEBUG_TORITO fprintf(stderr,"Looking for boot catalog file %s\n",bootpath); #endif if (!stat_filter(bootpath, &statbuf)) { /* * make sure its big enough to hold what we want */ if (statbuf.st_size == 2048) { /* * printf("Boot catalog exists, so we do nothing\n"); */ free(bootpath); return; } else { fprintf(stderr, "A boot catalog exists and appears corrupted.\n"); fprintf(stderr, "Please check the following file: %s.\n",bootpath); fprintf(stderr, "This file must be removed before a bootable CD can be done.\n"); free(bootpath); exit(1); } } /* * file does not exist, so we create it * make it one CD sector long */ bcat = open(bootpath, O_WRONLY | O_CREAT | O_BINARY, S_IROTH | S_IRGRP | S_IRWXU ); if (bcat == -1) { fprintf(stderr, "Error creating boot catalog, exiting...\n"); perror(""); exit(1); } buf = (char *) e_malloc( 2048 ); write(bcat, buf, 2048); close(bcat); free(bootpath); } /* init_boot_catalog(... */
int VMS_stat(char *path, struct stat * spnt) { char *spath; char sbuffer[255]; char *pnt, *ppnt; char *pnt1; ppnt = strrchr(path, ']'); if (ppnt) ppnt++; else ppnt = path; spath = path; if (strcmp(ppnt, ".") == 0 || strcmp(ppnt, "..") == 0) { strcpy(sbuffer, path); /* Find end of actual name */ pnt = strrchr(sbuffer, ']'); if (!pnt) return (0); pnt1 = pnt; while (*pnt1 != '[' && *pnt1 != '.') pnt1--; if (*pnt1 != '[' && strcmp(ppnt, "..") == 0) { pnt1--; while (*pnt1 != '[' && *pnt1 != '.') pnt1--; }; if (*pnt1 == '.') { *pnt1 = ']'; pnt = pnt1; while (*pnt != '.' && *pnt != ']') pnt++; *pnt++ = ']'; while (*pnt != '.' && *pnt != ']') pnt++; *pnt = 0; strcat(sbuffer, ".DIR;1"); }; if (*pnt1 == '[') { pnt1++; *pnt1 = 0; strcat(pnt1, "000000]"); pnt1 = strrchr(path, '[') + 1; pnt = sbuffer + strlen(sbuffer); while (*pnt1 && *pnt1 != '.' && *pnt1 != ']') *pnt++ = *pnt1++; *pnt = 0; strcat(sbuffer, ".DIR;1"); }; spath = sbuffer; }; return (stat_filter(spath, spnt)); }