Exemplo n.º 1
0
static int firefuse_truncate(const char *path, off_t size) {
  LOGTRACE2("firefuse_truncate(%s,%ld)", path, size);
  if (is_cv_path(path)) {
    return cve_truncate(path, size);
  }
  if (is_cnc_path(path)) {
    return cnc_truncate(path, size);
  }

  (void) size;
  if (strcmp(path, "/") == 0) {
    // directory
  } else if (strcmp(path, ECHO_PATH) == 0) {
    // NOP
  } else if (strcmp(path, FIRELOG_PATH) == 0) {
    // NOP
  } else if (strcmp(path, FIRESTEP_PATH) == 0) {
    // NOP
  } else {
    LOGERROR1("firefuse_truncate(%s) -> ENOENT", path);
    return -ENOENT;
  }
  LOGDEBUG1("firefuse_truncate %s", path);
  return 0;
}
Exemplo n.º 2
0
void firefuse_freeDataBuffer(const char *path, struct fuse_file_info *fi) {
    if (fi->fh) {
        FuseDataBuffer *pBuffer = (FuseDataBuffer *)(size_t) fi->fh;
        LOGTRACE2("firefuse_freeDataBuffer(%s) MEMORY-FREE: %ldB", path, (long) pBuffer->length);
        free(pBuffer);
        fi->fh = 0;
    }
}
Exemplo n.º 3
0
static int firefuse_rename(const char *path1, const char *path2) {
  LOGTRACE2("firefuse_rename(%s,%s)", path1, path2);
  if (is_cv_path(path1) && is_cv_path(path2)) {
    return cve_rename(path1, path2);
  }
  LOGERROR2("firefuse_rename(%s,%s) -> -ENOENT", path1, path2);
  return -ENOENT;
}
Exemplo n.º 4
0
static int firestep_readchar(int c) {
	switch (c) {
		case EOF:
      inbuf[inbuflen] = 0;
      inbuflen = 0;
      LOGERROR1("firestep_readchar %s[EOF]", inbuf);
      return 0;
		case '\n':
      inbuf[inbuflen] = 0;
      if (inbuflen) { // discard blank lines
				if (strncmp("{\"sr\"",inbuf, 5) == 0) {
					LOGDEBUG2("firestep_readchar %s (%dB)", inbuf, inbuflen);
				} else {
					LOGINFO2("firestep_readchar %s (%dB)", inbuf, inbuflen);
				}
      } else {
        inbufEmptyLine++;
				if (inbufEmptyLine % 1000 == 0) {
					LOGWARN1("firestep_readchar skipped %ld blank lines", inbufEmptyLine);
				}
			}
      inbuflen = 0;
			break;
		case '\r':
      // skip
			break;
		case 'a': case 'A':
		case 'b': case 'B':
		case 'c': case 'C':
		case 'd': case 'D':
		case 'e': case 'E':
		case 'f': case 'F':
		case 'g': case 'G':
		case 'h': case 'H':
		case 'i': case 'I':
		case 'j': case 'J':
		case 'k': case 'K':
		case 'l': case 'L':
		case 'm': case 'M':
		case 'n': case 'N':
		case 'o': case 'O':
		case 'p': case 'P':
		case 'q': case 'Q':
		case 'r': case 'R':
		case 's': case 'S':
		case 't': case 'T':
		case 'u': case 'U':
		case 'v': case 'V':
		case 'w': case 'W':
		case 'x': case 'X':
		case 'y': case 'Y':
		case 'z': case 'Z':
		case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
		case '.': case '-': case '_': case '/':
		case '{': case '}':
		case '(': case ')':
		case '[': case ']':
		case '<': case '>':
		case '"': case '\'': case ':': case ',':
		case ' ': case '\t':
			if (c == '{') {
				if (jsonDepth++ <= 0) {
					jsonLen = 0;
				}
				ADD_JSON(c);
			} else if (c == '}') {
				ADD_JSON(c);
				if (--jsonDepth < 0) {
					LOGWARN1("Invalid JSON %s", jsonBuf);
					return 0;
				}
			} else {
				ADD_JSON(c);
			}
      if (inbuflen >= INBUFMAX) {
				inbuf[INBUFMAX] = 0;
        LOGERROR1("firestep_readchar overflow %s", inbuf);
				break;
      } else {
        inbuf[inbuflen] = c;
        inbuflen++;
				LOGTRACE2("firestep_readchar %x %c", (int) c, (int) c);
      }
			break;
		default:
		  // discard unexpected character (probably wrong baud rate)
			LOGTRACE2("firestep_readchar %x ?", (int) c, (int) c);
		  break;
	}
	return 1;
}