Exemplo n.º 1
0
void Logger::LogFinishEvent(const NMEA_INFO &gps_info) {
  LogEvent(gps_info, "FIN");
}
Exemplo n.º 2
0
int nfs_Read(nfs_arg_t *parg,
             exportlist_t *pexport,
             fsal_op_context_t *pcontext,
             nfs_worker_data_t *pworker,
             struct svc_req *preq,
             nfs_res_t *pres)
{
  cache_entry_t *pentry;
  fsal_attrib_list_t attr;
  fsal_attrib_list_t pre_attr;
  cache_inode_status_t cache_status = CACHE_INODE_SUCCESS;
  size_t size = 0;
  size_t read_size = 0;
  fsal_off_t offset = 0;
  void *data = NULL;
  cache_inode_file_type_t filetype;
  fsal_boolean_t eof_met=FALSE;
  int rc = NFS_REQ_OK;

  if(isDebug(COMPONENT_NFSPROTO))
    {
      char str[LEN_FH_STR];

      switch (preq->rq_vers)
        {
        case NFS_V2:
          offset = parg->arg_read2.offset;
          size = parg->arg_read2.count;
          break;
        case NFS_V3:
          offset = parg->arg_read3.offset;
          size = parg->arg_read3.count;
        }

      nfs_FhandleToStr(preq->rq_vers,
                       &(parg->arg_read2.file),
                       &(parg->arg_read3.file),
                       NULL,
                       str);
      LogDebug(COMPONENT_NFSPROTO,
               "REQUEST PROCESSING: Calling nfs_Read handle: %s start: %llx len: %llx",
               str, (unsigned long long) offset, (unsigned long long) size);
    }

  if(preq->rq_vers == NFS_V3)
    {
      /* to avoid setting it on each error case */
      pres->res_read3.READ3res_u.resfail.file_attributes.attributes_follow = FALSE;
      /* initialize for read of size 0 */
      pres->res_read3.READ3res_u.resok.eof = FALSE;
      pres->res_read3.READ3res_u.resok.count = 0;
      pres->res_read3.READ3res_u.resok.data.data_val = NULL;
      pres->res_read3.READ3res_u.resok.data.data_len = 0;
      pres->res_read3.status = NFS3_OK;
    }
  else if(preq->rq_vers == NFS_V2)
    {
      /* initialize for read of size 0 */
      pres->res_read2.READ2res_u.readok.data.nfsdata2_val = NULL;
      pres->res_read2.READ2res_u.readok.data.nfsdata2_len = 0;
      pres->res_attr2.status = NFS_OK;
    }

  /* Convert file handle into a cache entry */
  if((pentry = nfs_FhandleToCache(preq->rq_vers,
                                  &(parg->arg_read2.file),
                                  &(parg->arg_read3.file),
                                  NULL,
                                  &(pres->res_read2.status),
                                  &(pres->res_read3.status),
                                  NULL, &pre_attr, pcontext, &rc)) == NULL)
    {
      /* Stale NFS FH ? */
      goto out;
    }

  if((preq->rq_vers == NFS_V3) && (nfs3_Is_Fh_Xattr(&(parg->arg_read3.file))))
  {
    rc = nfs3_Read_Xattr(parg, pexport, pcontext, preq, pres);
    goto out;
  }

  if(cache_inode_access(pentry,
                        FSAL_READ_ACCESS,
                        pcontext,
                        &cache_status) != CACHE_INODE_SUCCESS)
    {
      switch (preq->rq_vers)
        {
        case NFS_V2:
          pres->res_attr2.status = nfs2_Errno(cache_status);
          break;

        case NFS_V3:
          pres->res_read3.status = nfs3_Errno(cache_status);
          break;
        }
      rc = NFS_REQ_OK;
      goto out;
    }

  /* Extract the filetype */
  filetype = cache_inode_fsal_type_convert(pre_attr.type);

  /* Sanity check: read only from a regular file */
  if(filetype != REGULAR_FILE)
    {
      switch (preq->rq_vers)
        {
        case NFS_V2:
          /*
           * In the RFC tell it not good but it does
           * not tell what to do ... 
           */
          pres->res_attr2.status = NFSERR_ISDIR;
          break;

        case NFS_V3:
          if(filetype == DIRECTORY)
            pres->res_read3.status = NFS3ERR_ISDIR;
          else
            pres->res_read3.status = NFS3ERR_INVAL;
          break;
        }

      rc = NFS_REQ_OK;
      goto out;
    }

  /* For MDONLY export, reject write operation */
  /* Request of type MDONLY_RO were rejected at the nfs_rpc_dispatcher level */
  /* This is done by replying EDQUOT (this error is known for not disturbing the client's requests cache */
  if(pexport->access_type == ACCESSTYPE_MDONLY
     || pexport->access_type == ACCESSTYPE_MDONLY_RO)
    {
      switch (preq->rq_vers)
        {
        case NFS_V2:
          pres->res_attr2.status = NFSERR_DQUOT;
          break;

        case NFS_V3:
          pres->res_read3.status = NFS3ERR_DQUOT;
          break;
        }

      nfs_SetFailedStatus(pcontext, pexport,
                          preq->rq_vers,
                          cache_status,
                          &pres->res_read2.status,
                          &pres->res_read3.status,
                          pentry,
                          &(pres->res_read3.READ3res_u.resfail.file_attributes),
                          NULL, NULL, NULL, NULL, NULL, NULL);

      rc = NFS_REQ_OK;
      goto out;
    }

  /* Extract the argument from the request */
  switch (preq->rq_vers)
    {
    case NFS_V2:
      offset = parg->arg_read2.offset;  /* beginoffset is obsolete */
      size = parg->arg_read2.count;     /* totalcount is obsolete  */
      break;

    case NFS_V3:
      offset = parg->arg_read3.offset;
      size = parg->arg_read3.count;
      break;
    }

  /* 
   * do not exceed maxium READ offset if set 
   */
  if((pexport->options & EXPORT_OPTION_MAXOFFSETREAD) == EXPORT_OPTION_MAXOFFSETREAD)
    {
      LogFullDebug(COMPONENT_NFSPROTO,
                   "-----> Read offset=%llu count=%llu MaxOffSet=%llu",
                   (unsigned long long) offset,
                   (unsigned long long) size,
                   (unsigned long long) pexport->MaxOffsetRead);

      if((fsal_off_t) (offset + size) > pexport->MaxOffsetRead)
        {
          LogEvent(COMPONENT_NFSPROTO,
                   "NFS READ: A client tryed to violate max file size %llu for exportid #%hu",
                   (unsigned long long) pexport->MaxOffsetRead, pexport->id);

          switch (preq->rq_vers)
            {
            case NFS_V2:
              pres->res_attr2.status = NFSERR_DQUOT;
              break;

            case NFS_V3:
              pres->res_read3.status = NFS3ERR_INVAL;
              break;
            }

          nfs_SetFailedStatus(pcontext, pexport,
                              preq->rq_vers,
                              cache_status,
                              &pres->res_read2.status,
                              &pres->res_read3.status,
                              pentry,
                              &(pres->res_read3.READ3res_u.resfail.file_attributes),
                              NULL, NULL, NULL, NULL, NULL, NULL);

          rc = NFS_REQ_OK;
          goto out;
        }
    }

  /*
   * We should not exceed the FSINFO rtmax field for
   * the size 
   */
  if(((pexport->options & EXPORT_OPTION_MAXREAD) == EXPORT_OPTION_MAXREAD) &&
     size > pexport->MaxRead)
    {
      /*
       * The client asked for too much, normally
       * this should not happen because the client
       * is calling nfs_Fsinfo at mount time and so
       * is aware of the server maximum write size 
       */
      size = pexport->MaxRead;
    }

  if(size == 0)
    {
      nfs_read_ok(pexport, preq, pres, NULL, 0, &pre_attr, 0);
      rc = NFS_REQ_OK;
      goto out;
    }
  else
    {
      data = gsh_malloc(size);
      if(data == NULL)
        {
          rc = NFS_REQ_DROP;
          goto out;
        }

      if((cache_inode_rdwr(pentry,
                           CACHE_INODE_READ,
                           offset,
                           size,
                           &read_size,
                           data,
                           &eof_met,
                           pcontext,
                           CACHE_INODE_SAFE_WRITE_TO_FS,
                           &cache_status) == CACHE_INODE_SUCCESS) &&
         (cache_inode_getattr(pentry, &attr, pcontext,
                              &cache_status)) == CACHE_INODE_SUCCESS)

        {
          nfs_read_ok(pexport, preq, pres, data, read_size, &attr, 
                      ((offset + read_size) >= attr.filesize));
          rc = NFS_REQ_OK;
          goto out;
        }
      gsh_free(data);
    }

  /* If we are here, there was an error */
  if(nfs_RetryableError(cache_status))
    {
      rc = NFS_REQ_DROP;
      goto out;
    }

  nfs_SetFailedStatus(pcontext, pexport,
                      preq->rq_vers,
                      cache_status,
                      &pres->res_read2.status,
                      &pres->res_read3.status,
                      pentry,
                      &(pres->res_read3.READ3res_u.resfail.file_attributes),
                      NULL, NULL, NULL, NULL, NULL, NULL);

  rc = NFS_REQ_OK;

out:
  /* return references */
  if (pentry)
      cache_inode_put(pentry);

  return (rc);

}                               /* nfs_Read */
int nfs4_op_open_downgrade(struct nfs_argop4 *op, compound_data_t *data,
			   struct nfs_resop4 *resp)
{
	OPEN_DOWNGRADE4args * const arg_OPEN_DOWNGRADE4 =
		&op->nfs_argop4_u.opopen_downgrade;
	OPEN_DOWNGRADE4res * const res_OPEN_DOWNGRADE4 =
		&resp->nfs_resop4_u.opopen_downgrade;
	OPEN_DOWNGRADE4resok *resok =
		&res_OPEN_DOWNGRADE4->OPEN_DOWNGRADE4res_u.resok4;
	state_t *state_found = NULL;
	state_owner_t *open_owner;
	int rc;
	const char *tag = "OPEN_DOWNGRADE";
	char *cause = "";

	resp->resop = NFS4_OP_OPEN_DOWNGRADE;
	res_OPEN_DOWNGRADE4->status = NFS4_OK;

	/* Do basic checks on a filehandle */
	res_OPEN_DOWNGRADE4->status =
	    nfs4_sanity_check_FH(data, NO_FILE_TYPE, false);

	if (res_OPEN_DOWNGRADE4->status != NFS4_OK)
		return res_OPEN_DOWNGRADE4->status;

	/* Open downgrade is done only on a file */
	if (data->current_filetype != REGULAR_FILE) {
		res_OPEN_DOWNGRADE4->status = NFS4ERR_INVAL;
		return res_OPEN_DOWNGRADE4->status;
	}

	/* Check stateid correctness and get pointer to state */
	rc = nfs4_Check_Stateid(&arg_OPEN_DOWNGRADE4->open_stateid,
				data->current_obj,
				&state_found,
				data,
				STATEID_SPECIAL_FOR_LOCK,
				arg_OPEN_DOWNGRADE4->seqid,
				data->minorversion == 0,
				tag);

	if (rc != NFS4_OK && rc != NFS4ERR_REPLAY) {
		res_OPEN_DOWNGRADE4->status = rc;
		LogDebug(COMPONENT_STATE,
			 "OPEN_DOWNGRADE failed nfs4_Check_Stateid");
		return res_OPEN_DOWNGRADE4->status;
	}

	open_owner = get_state_owner_ref(state_found);

	if (open_owner == NULL) {
		/* Unexpected, but something just went stale. */
		res_OPEN_DOWNGRADE4->status = NFS4ERR_STALE;
		goto out2;
	}

	PTHREAD_MUTEX_lock(&open_owner->so_mutex);

	/* Check seqid */
	if (data->minorversion == 0 &&
	    !Check_nfs4_seqid(open_owner,
			      arg_OPEN_DOWNGRADE4->seqid,
			      op,
			      data->current_obj,
			      resp,
			      tag)) {
		/* Response is all setup for us and LogDebug told what was wrong
		 */
		PTHREAD_MUTEX_unlock(&open_owner->so_mutex);
		goto out;
	}

	PTHREAD_MUTEX_unlock(&open_owner->so_mutex);

	/* What kind of open is it ? */
	LogFullDebug(COMPONENT_STATE,
		     "OPEN_DOWNGRADE: Share Deny = %d Share Access = %d ",
		     arg_OPEN_DOWNGRADE4->share_deny,
		     arg_OPEN_DOWNGRADE4->share_access);

	res_OPEN_DOWNGRADE4->status = nfs4_do_open_downgrade(op,
							     data,
							     open_owner,
							     state_found,
							     &cause);

	if (res_OPEN_DOWNGRADE4->status != NFS4_OK) {
		LogEvent(COMPONENT_STATE,
			 "Failed to open downgrade: %s",
			 cause);
		goto out;
	}

	/* Successful exit */
	res_OPEN_DOWNGRADE4->status = NFS4_OK;

	/* Handle stateid/seqid for success */
	update_stateid(state_found, &resok->open_stateid, data, tag);

	/* Save the response in the open owner */
	if (data->minorversion == 0) {
		Copy_nfs4_state_req(open_owner,
				    arg_OPEN_DOWNGRADE4->seqid,
				    op,
				    data->current_obj,
				    resp,
				    tag);
	}

 out:

	dec_state_owner_ref(open_owner);

 out2:

	dec_state_t_ref(state_found);

	return res_OPEN_DOWNGRADE4->status;
}				/* nfs4_op_opendowngrade */
Exemplo n.º 4
0
int CStreamMuxerImp1::DoCreateStreamMuxer(BOOL fLive)
{
    //fLive = FALSE;
    m_bLive = fLive;

    if(!GetWritter())
    {
        return -1;
    }
    HRESULT hr = S_OK;


    //////////////////////////////////////////////////
    hr = SSFMuxCreate( &m_hSSFMux );
    if( FAILED(hr) )
    {
        char buf[1024];
        sprintf_s(buf, "Error 0x%08x: Failed to create SSF muxer\n", hr );
        LogEvent(buf);
        goto done;
    }

    hr = SSFMuxSetOption( m_hSSFMux, SSF_MUX_OPTION_LIVE_MODE, &fLive, sizeof(fLive) );
    if( FAILED(hr) )
    {
        char buf[1024];
        sprintf_s(buf, "Error 0x%08x: Failed to set SSF_MUX_OPTION_LIVE_MODE\n", hr );
        LogEvent(buf);
        goto done;
    }


    UINT64 timeScale = 10000000; // time scale in HNS means 10000000 HNS units in one second
    hr = SSFMuxSetOption( m_hSSFMux, SSF_MUX_OPTION_TIME_SCALE, &timeScale, sizeof(timeScale) );
    if( FAILED(hr) )
    {
        char buf[1024];
        sprintf_s( buf,"Error 0x%08x: Failed to set SSF_MUX_OPTION_TIME_SCALE\n", hr );
        LogEvent(buf);
        goto done;
    }

    BOOL fVariableBitRate = TRUE;

    hr = SSFMuxSetOption( m_hSSFMux, SSF_MUX_OPTION_VARIABLE_RATE, &fVariableBitRate, sizeof(fVariableBitRate) );
    if( FAILED(hr) )
    {
        char buf[1024];
        sprintf_s(buf, "Error 0x%08x: Failed to set SSF_MUX_OPTION_VARIABLE_RATE\n", hr );
        LogEvent(buf);
        goto done;
    }
    //////////////////////////////////


    return 0;

    //////////////////////////////////
done:
    if( NULL != m_hSSFMux )
    {
        SSFMuxDestroy( m_hSSFMux );
        m_hSSFMux = NULL;
    }
    return -1;
}
Exemplo n.º 5
0
void *_9p_socket_thread(void *Arg)
{
	long int tcp_sock = (long int)Arg;
	int rc = -1;
	struct pollfd fds[1];
	int fdcount = 1;
	static char my_name[MAXNAMLEN + 1];
	char strcaller[INET6_ADDRSTRLEN];
	request_data_t *req = NULL;
	int tag;
	unsigned long sequence = 0;
	unsigned int i = 0;
	char *_9pmsg = NULL;
	uint32_t msglen;

	struct _9p_conn _9p_conn;
	socklen_t addrpeerlen;

	int readlen = 0;
	int total_readlen = 0;

	snprintf(my_name, MAXNAMLEN, "9p_sock_mgr#fd=%ld", tcp_sock);
	SetNameFunction(my_name);

	/* Init the struct _9p_conn structure */
	memset(&_9p_conn, 0, sizeof(_9p_conn));
	PTHREAD_MUTEX_init(&_9p_conn.sock_lock, NULL);
	_9p_conn.trans_type = _9P_TCP;
	_9p_conn.trans_data.sockfd = tcp_sock;
	for (i = 0; i < FLUSH_BUCKETS; i++) {
		PTHREAD_MUTEX_init(&_9p_conn.flush_buckets[i].lock, NULL);
		glist_init(&_9p_conn.flush_buckets[i].list);
	}
	atomic_store_uint32_t(&_9p_conn.refcount, 0);

	/* Init the fids pointers array */
	memset(&_9p_conn.fids, 0, _9P_FID_PER_CONN * sizeof(struct _9p_fid *));

	/* Set initial msize.
	 * Client may request a lower value during TVERSION */
	_9p_conn.msize = _9p_param._9p_tcp_msize;

	if (gettimeofday(&_9p_conn.birth, NULL) == -1)
		LogFatal(COMPONENT_9P, "Cannot get connection's time of birth");

	addrpeerlen = sizeof(_9p_conn.addrpeer);
	rc = getpeername(tcp_sock, (struct sockaddr *)&_9p_conn.addrpeer,
			 &addrpeerlen);
	if (rc == -1) {
		LogMajor(COMPONENT_9P,
			 "Cannot get peername to tcp socket for 9p, error %d (%s)",
			 errno, strerror(errno));
		/* XXX */
		strncpy(strcaller, "(unresolved)", INET6_ADDRSTRLEN);
		strcaller[12] = '\0';
	} else {
		switch (_9p_conn.addrpeer.ss_family) {
		case AF_INET:
			inet_ntop(_9p_conn.addrpeer.ss_family,
				  &((struct sockaddr_in *)&_9p_conn.addrpeer)->
				  sin_addr, strcaller, INET6_ADDRSTRLEN);
			break;
		case AF_INET6:
			inet_ntop(_9p_conn.addrpeer.ss_family,
				  &((struct sockaddr_in6 *)&_9p_conn.addrpeer)->
				  sin6_addr, strcaller, INET6_ADDRSTRLEN);
			break;
		default:
			snprintf(strcaller, INET6_ADDRSTRLEN, "BAD ADDRESS");
			break;
		}

		LogEvent(COMPONENT_9P, "9p socket #%ld is connected to %s",
			 tcp_sock, strcaller);
	}
	_9p_conn.client = get_gsh_client(&_9p_conn.addrpeer, false);

	/* Set up the structure used by poll */
	memset((char *)fds, 0, sizeof(struct pollfd));
	fds[0].fd = tcp_sock;
	fds[0].events =
	    POLLIN | POLLPRI | POLLRDBAND | POLLRDNORM | POLLRDHUP | POLLHUP |
	    POLLERR | POLLNVAL;

	for (;;) {
		total_readlen = 0;  /* new message */
		rc = poll(fds, fdcount, -1);
		if (rc == -1) {
			/* timeout = -1 => Wait indefinitely for events */
			/* Interruption if not an issue */
			if (errno == EINTR)
				continue;

			LogCrit(COMPONENT_9P,
				"Got error %u (%s) on fd %ld connect to %s while polling on socket",
				errno, strerror(errno), tcp_sock, strcaller);
		}

		if (fds[0].revents & POLLNVAL) {
			LogEvent(COMPONENT_9P,
				 "Client %s on socket %lu produced POLLNVAL",
				 strcaller, tcp_sock);
			goto end;
		}

		if (fds[0].revents & (POLLERR | POLLHUP | POLLRDHUP)) {
			LogEvent(COMPONENT_9P,
				 "Client %s on socket %lu has shut down and closed",
				 strcaller, tcp_sock);
			goto end;
		}

		if (!(fds[0].revents & (POLLIN | POLLRDNORM)))
			continue;

		/* Prepare to read the message */
		_9pmsg = gsh_malloc(_9p_conn.msize);
		if (_9pmsg == NULL) {
			LogCrit(COMPONENT_9P,
				"Could not allocate 9pmsg buffer for client %s on socket %lu",
				strcaller, tcp_sock);
			goto end;
		}

		/* An incoming 9P request: the msg has a 4 bytes header
		   showing the size of the msg including the header */
		readlen = recv(fds[0].fd, _9pmsg,
			       _9P_HDR_SIZE, MSG_WAITALL);
		if (readlen != _9P_HDR_SIZE)
			goto badmsg;

		msglen = *(uint32_t *) _9pmsg;
		if (msglen > _9p_conn.msize) {
			LogCrit(COMPONENT_9P,
				"Message size too big! got %u, max = %u",
				msglen, _9p_conn.msize);
			goto end;
		}

		LogFullDebug(COMPONENT_9P,
			     "Received 9P/TCP message of size %u from client %s on socket %lu",
			     msglen, strcaller, tcp_sock);

		total_readlen += readlen;
		while (total_readlen < msglen) {
			readlen = recv(fds[0].fd,
				       _9pmsg + total_readlen,
				       msglen - total_readlen,
				       0);

			if (readlen > 0) {
				total_readlen += readlen;
				continue;
			}
			if (readlen == 0 ||
			    (readlen < 0 && errno != EINTR))
				goto badmsg;
		}	/* while */

		server_stats_transport_done(_9p_conn.client,
					    total_readlen, 1, 0,
					    0, 0, 0);

		/* Message is good. */
		req = pool_alloc(request_pool, NULL);
		if (req == NULL) {
			LogCrit(COMPONENT_9P,
				"Could not allocate memory from request pool");
			goto end;
		}

		req->rtype = _9P_REQUEST;
		req->r_u._9p._9pmsg = _9pmsg;
		req->r_u._9p.pconn = &_9p_conn;

		/* Add this request to the request list,
		 * should it be flushed later. */
		tag = *(u16 *) (_9pmsg + _9P_HDR_SIZE +
				_9P_TYPE_SIZE);
		_9p_AddFlushHook(&req->r_u._9p, tag,
				 sequence++);
		LogFullDebug(COMPONENT_9P,
			     "Request tag is %d\n", tag);

		/* Message was OK push it */
		DispatchWork9P(req);

		/* Not our buffer anymore */
		_9pmsg = NULL;
		continue;

badmsg:
		if (readlen == 0)
			LogEvent(COMPONENT_9P,
				 "Premature end for Client %s on socket %lu, total read = %u",
				 strcaller, tcp_sock, total_readlen);
		else if (readlen < 0) {
			LogEvent(COMPONENT_9P,
				 "Read error client %s on socket %lu errno=%d, total read = %u",
				 strcaller, tcp_sock,
				 errno, total_readlen);
		} else
			LogEvent(COMPONENT_9P,
				 "Header too small! for client %s on socket %lu: readlen=%u expected=%u",
				 strcaller, tcp_sock, readlen,
				 _9P_HDR_SIZE);

		/* Either way, we close the connection.
		 * It is not possible to survive
		 * once we get out of sync in the TCP stream
		 * with the client
		 */
		break; /* bail out */
	}			/* for( ;; ) */

end:
	LogEvent(COMPONENT_9P, "Closing connection on socket %lu", tcp_sock);
	close(tcp_sock);

	/* Free buffer if we encountered an error
	 * before we could give it to a worker */
	if (_9pmsg)
		gsh_free(_9pmsg);

	while (atomic_fetch_uint32_t(&_9p_conn.refcount)) {
		LogEvent(COMPONENT_9P, "Waiting for workers to release pconn");
		sleep(1);
	}

	_9p_cleanup_fids(&_9p_conn);

	if (_9p_conn.client != NULL)
		put_gsh_client(_9p_conn.client);

	pthread_exit(NULL);
}				/* _9p_socket_thread */
Exemplo n.º 6
0
int nfs_ip_name_add(sockaddr_t *ipaddr, char *hostname, size_t size)
{
	struct gsh_buffdesc buffkey;
	struct gsh_buffdesc buffdata;
	nfs_ip_name_t *nfs_ip_name = NULL;
	sockaddr_t *pipaddr = NULL;
	struct timeval tv0, tv1, dur;
	int rc;
	char ipstring[SOCK_NAME_MAX + 1];

	nfs_ip_name = gsh_malloc(sizeof(nfs_ip_name_t));

	pipaddr = gsh_malloc(sizeof(sockaddr_t));

	/* I have to keep an integer as key, I wil use the pointer buffkey->addr
	 * for this, this also means that buffkey->len will be 0
	 */
	memcpy(pipaddr, ipaddr, sizeof(sockaddr_t));

	buffkey.addr = pipaddr;
	buffkey.len = sizeof(sockaddr_t);

	gettimeofday(&tv0, NULL);
	rc = getnameinfo((struct sockaddr *)pipaddr, sizeof(sockaddr_t),
			 nfs_ip_name->hostname, sizeof(nfs_ip_name->hostname),
			 NULL, 0, 0);
	gettimeofday(&tv1, NULL);
	timersub(&tv1, &tv0, &dur);

	sprint_sockip(pipaddr, ipstring, sizeof(ipstring));

	/* display warning if DNS resolution took more that 1.0s */
	if (dur.tv_sec >= 1) {
		LogEvent(COMPONENT_DISPATCH,
			 "Warning: long DNS query for %s: %u.%06u sec",
			 ipstring, (unsigned int)dur.tv_sec,
			 (unsigned int)dur.tv_usec);
	}

	/* Ask for the name to be cached */
	if (rc != 0) {
		strmaxcpy(nfs_ip_name->hostname, ipstring,
			sizeof(nfs_ip_name->hostname));
		LogEvent(COMPONENT_DISPATCH,
			 "Cannot resolve address %s, error %s, using %s as hostname",
			 ipstring, gai_strerror(rc), nfs_ip_name->hostname);
	}

	LogDebug(COMPONENT_DISPATCH, "Inserting %s->%s to addr cache", ipstring,
		 nfs_ip_name->hostname);

	/* I build the data with the request pointer
	 * that should be in state 'IN USE'
	 */
	nfs_ip_name->timestamp = time(NULL);

	buffdata.addr = nfs_ip_name;
	buffdata.len = sizeof(nfs_ip_name_t);

	if (HashTable_Set(ht_ip_name, &buffkey, &buffdata) != HASHTABLE_SUCCESS)
		return IP_NAME_INSERT_MALLOC_ERROR;

	/* Copy the value for the caller */
	strmaxcpy(hostname, nfs_ip_name->hostname, size);

	return IP_NAME_SUCCESS;
}				/* nfs_ip_name_add */
Exemplo n.º 7
0
BOOL CNTService::Install()
{
    // Open the Service Control Manager
    SC_HANDLE hSCM = ::OpenSCManager( NULL,						// local machine
                                      NULL,						// ServicesActive database
                                      SC_MANAGER_ALL_ACCESS);	// full access
    if ( !hSCM ) {
        return FALSE;
    }

    // Get the executable file path
    WCHAR szFilePath[_MAX_PATH];
    ::GetModuleFileName(NULL, szFilePath, sizeof(szFilePath));

    // Create the service
    SC_HANDLE hService = ::CreateService( hSCM,
                                          m_szServiceName,
                                          m_szServiceName,
                                          SERVICE_ALL_ACCESS,
                                          SERVICE_WIN32_OWN_PROCESS,
                                          SERVICE_DEMAND_START,	// start condition
                                          SERVICE_ERROR_NORMAL,
                                          szFilePath,
                                          NULL,
                                          NULL,
                                          NULL,
                                          NULL,
                                          NULL );
    if ( !hService ) {
        ::CloseServiceHandle(hSCM);
        return FALSE;
    }

    // make registry entries to support logging messages
    // Add the source name as a subkey under the Application
    // key in the EventLog service portion of the registry.
    WCHAR szKey[256];
    HKEY hKey = NULL;
    wcscpy( szKey, _("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\") );
    wcscpy( szKey, m_szServiceName );
    if ( ::RegCreateKey(HKEY_LOCAL_MACHINE, szKey, &hKey) != ERROR_SUCCESS ) {
        ::CloseServiceHandle( hService );
        ::CloseServiceHandle( hSCM );
        return FALSE;
    }

    // Add the Event ID message-file name to the 'EventMessageFile' subkey.
    ::RegSetValueEx( hKey,
                        _("EventMessageFile"),
                        0,
                        REG_EXPAND_SZ, 
                        (CONST BYTE*)szFilePath,
                        wcslen(szFilePath) + 1 );     

    // Set the supported types flags.
    DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
    ::RegSetValueEx( hKey,
                        _("TypesSupported"),
                        0,
                        REG_DWORD,
                        (CONST BYTE*)&dwData,
                        sizeof(DWORD) );
    ::RegCloseKey(hKey);

    LogEvent( EVENTLOG_INFORMATION_TYPE, EVMSG_INSTALLED, m_szServiceName );

    // tidy up
    ::CloseServiceHandle( hService );
    ::CloseServiceHandle( hSCM );

    return TRUE;
}
Exemplo n.º 8
0
void MyListCtrl::OnDeselected(wxListEvent& event)
{
    LogEvent(event, wxT("OnDeselected"));
}
Exemplo n.º 9
0
void MyListCtrl::OnActivated(wxListEvent& event)
{
    LogEvent(event, wxT("OnActivated"));
}
Exemplo n.º 10
0
void MyListCtrl::OnDeleteItem(wxListEvent& event)
{
    LogEvent(event, wxT("OnDeleteItem"));
    wxLogMessage( wxT("Number of items when delete event is sent: %d"), GetItemCount() );
}
Exemplo n.º 11
0
void MyListCtrl::OnDeleteAllItems(wxListEvent& event)
{
    LogEvent(event, wxT("OnDeleteAllItems"));
}
Exemplo n.º 12
0
void CGroupViewTester::HandleContactViewEvent( const CContactViewBase& aView,
    const TContactViewEvent& aEvent )
	{
    // Log events from both underlying view and group view.
    LogEvent( const_cast<TContactViewEvent&>( aEvent ) );

	switch (iCurrentTest)
		{
		case ECreateLocalView:
			test(iLocalView==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;

		case ECreateGroupOneView:
			{
			test(iGroupViewOne == &aView);
			test(aEvent.iEventType == TContactViewEvent::EReady);

			//Reserve the IDs of last three contacts in the group
			TInt index = KNumContactsInGroupOne-1;
            TRAPD(err, iLastContactID = iGroupViewOne->ContactAtL(index).Id() );
			if (err)
				{
				_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning iLastContactID\n");
				test.Printf(KErrMsg);
				User::Invariant();
				}

            --index;
            TRAP(err, iSecondLastContactID = iGroupViewOne->ContactAtL(index).Id() );
			if (err)
				{
				_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning iSecondLastContactID\n");
				test.Printf(KErrMsg);
				User::Invariant();
				}

            --index;
            TRAP(err, iThirdLastContactID = iGroupViewOne->ContactAtL(index).Id() );
			if (err)
				{
				_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning iThirdLastContactID\n");
				test.Printf(KErrMsg);
				User::Invariant();
				}

			}
			break;

        case ECreateGroupTwoView:
			test( iGroupViewTwo == &aView );
			test( aEvent.iEventType == TContactViewEvent::EReady );
            break;

        case EDeleteItemsFromView:
            {
            // Bulk delete complete when the last Ready is received from the 
            // base view. This comes after the group view ready event. Break to 
            // run next test.
            TBool lastEvent = (aEvent.iEventType == TContactViewEvent::EReady) &&
                (&aView == iLocalView);
            if (lastEvent) 
                { 
                break; 
                }

            if (aEvent.iEventType == TContactViewEvent::EItemRemoved)
                {
                // Only proces events from group view.
                if (&aView == iGroupViewOne)
                    {
                    // Ensure that only 1 contact is removed per notification.
                     iNumRemovedEvents++;
                    TInt numItemsExpected = KNumContactsInGroupOne - iNumRemovedEvents;
		            
		            TInt numItems(0);
		            TRAPD(err, numItems = iGroupViewOne->CountL() );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning numItems\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
		            test(numItems == numItemsExpected );

                    // Verify the contacts were deleted as expected.
                    TBool testVal(EFalse);
                    TInt index = numItemsExpected - 1;
					TRAP(err, testVal = (iGroupViewOne->ContactAtL(index).Id() == iLastContactID) );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning testVal for iLastContactID\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
					test(testVal);

                    --index;
					TRAP(err, testVal = (iGroupViewOne->ContactAtL(index).Id() == iSecondLastContactID) );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning testVal for iSecondLastContactID\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
					test(testVal);

                    --index;
					TRAP(err, testVal = (iGroupViewOne->ContactAtL(index).Id() == iThirdLastContactID) );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning testVal for iThirdLastContactID\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
					test(testVal);
                    }

                // More events expected, don't run next test.
                return;
                }
            else
                {
                // Ignore all other events.
                return;
                }
            }

        case EAddItemToGroup:
            {
            // Break to run next test if this is the last expected event. The last
            // event is the group being added from the base view. The local view
            // removes and then adds the group id whenever the group changes. These
            // events are meaningless.
            TBool lastEvent = (&aView == iLocalView) && 
                (aEvent.iEventType == TContactViewEvent::EItemAdded) &&
                (aEvent.iContactId == iGroupOneId);
            if (lastEvent)
                {
                break; // Run next test.
                }

            // Verify contact has been added.
            if (aEvent.iEventType == TContactViewEvent::EItemAdded && 
                &aView == iGroupViewOne)
                {
                // Check if contact was added.
                test( aEvent.iContactId == iIdAdded );

                TInt index = iGroupViewOne->FindL( iIdAdded );
                test (index != KErrNotFound);

                // More events expected, don't run next test.
                return;
                }
            else
                {
                // Ignore all other events.
                return;
                }
            }

		default:
			test( EFalse );
			break;
		}

    // Run the next test.
	if (--iNumNotificationExpected <= 0)
		{
		NextTest();
		iNumNotificationExpected = 0;
		}
	}
Exemplo n.º 13
0
void Logger::LogTurnpointEvent(const NMEA_INFO &gps_info) {
  LogEvent(gps_info, "TPC");
}
Exemplo n.º 14
0
void Logger::LogPilotEvent(const NMEA_INFO &gps_info) {
  LogEvent(gps_info, "PEV");
}
Exemplo n.º 15
0
/**
 * FSAL_proxy_clientid_renewer_thread: this thread is made for refreshing the clientid used by the FSAL, automatically.
 *
 *  This thread is made for refreshing the clientid used by the FSAL, automatically.
 *
 *
 * \return never returns... This is a infinite loop that will die when the daemon stops
 */
void *FSAL_proxy_clientid_renewer_thread(void *Arg)
{
  int rc;

  COMPOUND4args argnfs4;
  COMPOUND4res resnfs4;
  struct timeval timeout = TIMEOUTRPC;
  fsal_status_t fsal_status;
  proxyfsal_op_context_t fsal_context;
  proxyfsal_op_context_t *p_context = &fsal_context;
#define FSAL_RENEW_LEASE_NB_OP_ALLOC 1
  nfs_argop4 argoparray[FSAL_RENEW_LEASE_NB_OP_ALLOC];
  nfs_resop4 resoparray[FSAL_RENEW_LEASE_NB_OP_ALLOC];
#ifndef _NO_BUDDY_SYSTEM
  buddy_parameter_t buddy_param = default_buddy_parameter;
#endif

  LogEvent(COMPONENT_FSAL, "FSAL_proxy_clientid_refresher_thread: starting...");

  sleep(6);    /** @todo: use getattr to have an actual value of server's lease duration */

#ifndef _NO_BUDDY_SYSTEM
  if((rc = BuddyInit(&buddy_param)) != BUDDY_SUCCESS)
    {
      /* Failed init */
      LogCrit(COMPONENT_FSAL,
          "FSAL_proxy_clientid_renewer_thread: Memory manager could not be initialized, exiting...");
      exit(1);
    }
#endif

  memset((char *)&fsal_context, 0, sizeof(proxyfsal_op_context_t));
  fsal_status = PROXYFSAL_InitClientContext(p_context);

  if(FSAL_IS_ERROR(fsal_status))
    {
      LogCrit(COMPONENT_FSAL,
           "FSAL_proxy_clientid_refresher_thread: FSAL error(%u,%u) during init... exiting",
           fsal_status.major, fsal_status.minor);
      exit(1);
    }

  /* Setup results structures */
  argnfs4.argarray.argarray_val = argoparray;
  resnfs4.resarray.resarray_val = resoparray;
  argnfs4.minorversion = 0;
  argnfs4.tag.utf8string_val = NULL;
  argnfs4.tag.utf8string_len = 0;
  argnfs4.argarray.argarray_len = 0;

  argnfs4.argarray.argarray_val[0].argop = NFS4_OP_RENEW;
  argnfs4.argarray.argarray_val[0].nfs_argop4_u.oprenew.clientid = fsal_clientid;
  argnfs4.argarray.argarray_len = 1;

  while(1)
    {
      sleep(60);  /** @todo: use getattr to have an actual value of server's lease duration */

      /* Call the NFSv4 function */
      TakeTokenFSCall();

      COMPOUNDV4_EXECUTE(p_context, argnfs4, resnfs4, rc);
      if(rc != RPC_SUCCESS)
        {
          ReleaseTokenFSCall();

          LogCrit(COMPONENT_FSAL, "FSAL_PROXY: /!\\ RPC error when connecting to the server");

        }

      ReleaseTokenFSCall();

      if(resnfs4.status != NFS4_OK)
        LogCrit(COMPONENT_FSAL,
                "FSAL_PROXY: /!\\ NFSv4 error %u occured when trying to new clienitf %llu",
                resnfs4.status, (long long unsigned int)fsal_clientid);

    }                           /* while( 1 ) */
}                               /* FSAL_proxy_clientid_renewer_thread */
Exemplo n.º 16
0
void MyListCtrl::OnFocused(wxListEvent& event)
{
    LogEvent(event, wxT("OnFocused"));

    event.Skip();
}
Exemplo n.º 17
0
/**
 * FSAL_proxy_setclientid_force:
 * Client ID negociation 
 *
 * \param p_context (input):
 *        Authentication context for the operation (user,...).
 *
 * \return Major error codes :
 *        - ERR_FSAL_NO_ERROR     (no error)
 *        - ERR_FSAL_FAULT        (a NULL pointer was passed as mandatory argument)
 *        - Other error codes can be returned :
 *          ERR_FSAL_ACCESS, ERR_FSAL_IO, ...
 */
fsal_status_t FSAL_proxy_setclientid_force(proxyfsal_op_context_t * p_context)
{
  int rc;
  fsal_status_t fsal_status;
  COMPOUND4args argnfs4;
  COMPOUND4res resnfs4;

#define FSAL_CLIENTID_NB_OP_ALLOC 1
  nfs_argop4 argoparray[FSAL_CLIENTID_NB_OP_ALLOC];
  nfs_resop4 resoparray[FSAL_CLIENTID_NB_OP_ALLOC];

  nfs_client_id4 nfsclientid;
  cb_client4 cbproxy;
  char clientid_name[MAXNAMLEN];
  char cbaddr[MAXNAMLEN];
  char cbnetid[MAXNAMLEN];
  clientid4 resultclientid;
  struct timeval timeout = TIMEOUTRPC;

  LogEvent( COMPONENT_FSAL, "Negociating a new ClientId with the remote server" ) ;

  /* sanity checks.
   */
  if(!p_context)
    Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_InitClientContext);

  /* Client id negociation is to be done only one time for the whole FSAL */
  P(fsal_clientid_mutex_renew);

  /* Setup results structures */
  argnfs4.argarray.argarray_val = argoparray;
  resnfs4.resarray.resarray_val = resoparray;
  argnfs4.minorversion = 0;
  argnfs4.tag.utf8string_val = NULL;
  argnfs4.tag.utf8string_len = 0;
  argnfs4.argarray.argarray_len = 0;

  snprintf(clientid_name, MAXNAMLEN, "GANESHA NFSv4 Proxy Pid=%u", getpid());
  nfsclientid.id.id_len = strlen(clientid_name);
  nfsclientid.id.id_val = clientid_name;
  snprintf(nfsclientid.verifier, NFS4_VERIFIER_SIZE, "%x", (int)ServerBootTime);

  cbproxy.cb_program = 0;
  strncpy(cbnetid, "tcp", MAXNAMLEN);
  strncpy(cbaddr, "127.0.0.1", MAXNAMLEN);
#ifdef _USE_NFS4_1
  cbproxy.cb_location.na_r_netid = cbnetid;
  cbproxy.cb_location.na_r_addr = cbaddr;
#else
  cbproxy.cb_location.r_netid = cbnetid;
  cbproxy.cb_location.r_addr = cbaddr;
#endif

  COMPOUNDV4_ARG_ADD_OP_SETCLIENTID(argnfs4, nfsclientid, cbproxy);

  TakeTokenFSCall();

  p_context->user_credential.user = 0;
  p_context->user_credential.group = 0;
  p_context->user_credential.nbgroups = 0;

  /* Call the NFSv4 function */
  rc = COMPOUNDV4_EXECUTE_SIMPLE(p_context, argnfs4, resnfs4);
  if(rc != RPC_SUCCESS)
    {
      ReleaseTokenFSCall();

      V(fsal_clientid_mutex_renew);

      Return(ERR_FSAL_IO, rc, INDEX_FSAL_unlink);
    }

  ReleaseTokenFSCall();

  if(resnfs4.status != NFS4_OK)
    {
      V(fsal_clientid_mutex_renew);
      return fsal_internal_proxy_error_convert(resnfs4.status,
                                               INDEX_FSAL_InitClientContext);
    }

  resultclientid =
      resnfs4.resarray.resarray_val[0].nfs_resop4_u.opsetclientid.SETCLIENTID4res_u.
      resok4.clientid;

  /* Step 2: Confirm the client id */
  argnfs4.minorversion = 0;
  argnfs4.tag.utf8string_val = NULL;
  argnfs4.tag.utf8string_len = 0;
  argnfs4.argarray.argarray_len = 0;

  argnfs4.argarray.argarray_val[0].argop = NFS4_OP_SETCLIENTID_CONFIRM;
  argnfs4.argarray.argarray_val[0].nfs_argop4_u.opsetclientid_confirm.clientid =
      resnfs4.resarray.resarray_val[0].nfs_resop4_u.opsetclientid.SETCLIENTID4res_u.
      resok4.clientid;
  memcpy((char *)argnfs4.argarray.argarray_val[0].nfs_argop4_u.opsetclientid_confirm.
         setclientid_confirm,
         (char *)resnfs4.resarray.resarray_val[0].nfs_resop4_u.opsetclientid.
         SETCLIENTID4res_u.resok4.setclientid_confirm, NFS4_VERIFIER_SIZE);
  argnfs4.argarray.argarray_len = 1;

  /* Call the NFSv4 function */
  rc = COMPOUNDV4_EXECUTE_SIMPLE(p_context, argnfs4, resnfs4);
  if(rc != RPC_SUCCESS)
    {
      ReleaseTokenFSCall();

      V(fsal_clientid_mutex_renew);

      Return(ERR_FSAL_IO, rc, INDEX_FSAL_unlink);
    }

  ReleaseTokenFSCall();

  if(resnfs4.status != NFS4_OK)
    return fsal_internal_proxy_error_convert(resnfs4.status,
                                             INDEX_FSAL_InitClientContext);

  /* Keep the confirmed client id */
  fsal_clientid =
      argnfs4.argarray.argarray_val[0].nfs_argop4_u.opsetclientid_confirm.clientid;
  clientid_renewed = time( NULL ) ;

  V(fsal_clientid_mutex_renew);

  p_context->clientid = fsal_clientid;
  p_context->last_lease_renewal = 0;    /* Needs to be renewed */

  fsal_status.major = ERR_FSAL_NO_ERROR;
  fsal_status.minor = 0;

  return fsal_status;
}                               /* FSAL_proxy_setclientid_force */
Exemplo n.º 18
0
void MyListCtrl::OnListKeyDown(wxListEvent& event)
{
    long item;

    if ( !wxGetKeyState(WXK_SHIFT) )
    {
        LogEvent(event, wxT("OnListKeyDown"));
        event.Skip();
        return;
    }

    switch ( event.GetKeyCode() )
    {
        case 'C': // colorize
            {
                wxListItem info;
                info.m_itemId = event.GetIndex();
                if ( info.m_itemId == -1 )
                {
                    // no item
                    break;
                }

                GetItem(info);

                wxListItemAttr *attr = info.GetAttributes();
                if ( !attr || !attr->HasTextColour() )
                {
                    info.SetTextColour(*wxCYAN);

                    SetItem(info);

                    RefreshItem(info.m_itemId);
                }
            }
            break;

        case 'N': // next
            item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
            if ( item++ == GetItemCount() - 1 )
            {
                item = 0;
            }

            wxLogMessage(wxT("Focusing item %ld"), item);

            SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
            EnsureVisible(item);
            break;

        case 'R': // show bounding rectangle
            {
                item = event.GetIndex();
                wxRect r;
                if ( !GetItemRect(item, r) )
                {
                    wxLogError(wxT("Failed to retrieve rect of item %ld"), item);
                    break;
                }

                wxLogMessage(wxT("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
                             item, r.x, r.y, r.x + r.width, r.y + r.height);
            }
            break;

        case '1': // show sub item bounding rectangle for the given column
        case '2': // (and icon/label rectangle if Shift/Ctrl is pressed)
        case '3':
        case '4': // this column is invalid but we want to test it too
            if ( InReportView() )
            {
                int subItem = event.GetKeyCode() - '1';
                item = event.GetIndex();
                wxRect r;

                int code = wxLIST_RECT_BOUNDS;
                if ( wxGetKeyState(WXK_SHIFT) )
                    code = wxLIST_RECT_ICON;
                else if ( wxGetKeyState(WXK_CONTROL) )
                    code = wxLIST_RECT_LABEL;

                if ( !GetSubItemRect(item, subItem, r, code) )
                {
                    wxLogError(wxT("Failed to retrieve rect of item %ld column %d"), item, subItem + 1);
                    break;
                }

                wxLogMessage(wxT("Bounding rect of item %ld column %d is (%d, %d)-(%d, %d)"),
                             item, subItem + 1,
                             r.x, r.y, r.x + r.width, r.y + r.height);
            }
            break;

        case 'U': // update
            if ( !IsVirtual() )
                break;

            if ( m_updated != -1 )
                RefreshItem(m_updated);

            m_updated = event.GetIndex();
            if ( m_updated != -1 )
            {
                // we won't see changes to this item as it's selected, update
                // the next one (or the first one if we're on the last item)
                if ( ++m_updated == GetItemCount() )
                    m_updated = 0;

                wxLogMessage("Updating colour of the item %ld", m_updated);
                RefreshItem(m_updated);
            }
            break;

        case 'D': // delete
            item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            while ( item != -1 )
            {
                DeleteItem(item);

                wxLogMessage(wxT("Item %ld deleted"), item);

                // -1 because the indices were shifted by DeleteItem()
                item = GetNextItem(item - 1,
                                   wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            }
            break;

        case 'I': // insert
            if ( GetWindowStyle() & wxLC_REPORT )
            {
                if ( GetWindowStyle() & wxLC_VIRTUAL )
                {
                    SetItemCount(GetItemCount() + 1);
                }
                else // !virtual
                {
                    InsertItemInReportView(event.GetIndex());
                }
            }
            //else: fall through

        default:
            LogEvent(event, wxT("OnListKeyDown"));

            event.Skip();
    }
}
Exemplo n.º 19
0
cache_inode_status_t
cache_inode_commit(cache_entry_t * pentry,
                   uint64_t offset,
                   fsal_size_t count,
                   fsal_attrib_list_t * pfsal_attr,
                   hash_table_t * ht,
                   cache_inode_client_t * pclient,
                   fsal_op_context_t * pcontext,
                   uint64_t typeofcommit,
                   cache_inode_status_t * pstatus)
{
    cache_inode_status_t status;
    fsal_seek_t seek_descriptor;
    fsal_size_t size_io_done;
    fsal_boolean_t eof;
    cache_inode_unstable_data_t *udata;
    fsal_status_t fsal_status;

    /* Do not use this function is Data Cache is used */
    if(pentry->object.file.pentry_content != NULL)
     {
            *pstatus = CACHE_INODE_SUCCESS;
            return *pstatus;
     }

    /* If we aren't using the Ganesha write buffer, then we're using the filesystem
     * write buffer so execute a normal fsal_sync() call. */
    if (typeofcommit == FSAL_UNSAFE_WRITE_TO_FS_BUFFER)
    {

      P_w(&pentry->lock);

      /* Can't sync a file descriptor if it's currently closed. */
      if(cache_inode_open(pentry,
                          pclient,
                          FSAL_O_WRONLY, pcontext, pstatus) != CACHE_INODE_SUCCESS)
        {

          V_w(&pentry->lock);
          
          /* stats */
          pclient->stat.func_stats.nb_err_unrecover[CACHE_INODE_COMMIT] += 1;
          
          return *pstatus;
        }

#ifdef _USE_MFSL      
      fsal_status = MFSL_sync(&(pentry->object.file.open_fd.mfsl_fd), NULL); 
#else
      fsal_status = FSAL_sync(&(pentry->object.file.open_fd.fd));
#endif
      if(FSAL_IS_ERROR(fsal_status))
      {
        LogMajor(COMPONENT_CACHE_INODE,
                 "cache_inode_rdwr: fsal_sync() failed: fsal_status.major = %d",
                 fsal_status.major);

      /* Close the fd that we just opened before the FSAL_sync(). We are already
       * replying with an error. No need to catch an additional error form 
       * a close? */
         cache_inode_close(pentry, pclient, &status);

        V_w(&pentry->lock);

        /* stats */
        pclient->stat.func_stats.nb_err_unrecover[CACHE_INODE_COMMIT] += 1;

        *pstatus = CACHE_INODE_FSAL_ERROR;
        return *pstatus;
      }
      *pstatus = CACHE_INODE_SUCCESS;

      /* Close the fd that we just opened before the FSAL_sync() */
      if(cache_inode_close(pentry, pclient, pstatus) != CACHE_INODE_SUCCESS)
        {
          LogEvent(COMPONENT_CACHE_INODE,
                   "cache_inode_rdwr: cache_inode_close = %d",
                   *pstatus);
          
          V_w(&pentry->lock);
          
          /* stats */
          pclient->stat.func_stats.nb_err_unrecover[CACHE_INODE_COMMIT] += 1;
          
          return *pstatus;
        }

      V_w(&pentry->lock);      
      return *pstatus;
    }

    /* Ok, it looks like we're using the Ganesha write buffer. This means we
     * will either be writing to the buffer, or writing a stable write to the
     * file system if the buffer is already full. */

    udata = &pentry->object.file.unstable_data;
    if(udata->buffer == NULL)
        {
            *pstatus = CACHE_INODE_SUCCESS;
            return *pstatus;
        }
    if(count == 0 || count == 0xFFFFFFFFL)
        {
            /* Count = 0 means "flush all data to permanent storage */
            seek_descriptor.offset = udata->offset;
            seek_descriptor.whence = FSAL_SEEK_SET;

            status = cache_inode_rdwr(pentry,
                                      CACHE_INODE_WRITE,
                                      &seek_descriptor, udata->length,
                                      &size_io_done, pfsal_attr,
                                      udata->buffer, &eof, ht,
                                      pclient, pcontext, TRUE, pstatus);
            if (status != CACHE_INODE_SUCCESS)
                return *pstatus;

            P_w(&pentry->lock);

            Mem_Free(udata->buffer);
            udata->buffer = NULL;

            V_w(&pentry->lock);
        }
    else
        {
            if(offset < udata->offset)
                {
                    *pstatus = CACHE_INODE_INVALID_ARGUMENT;
                    return *pstatus;
                }

            seek_descriptor.offset = offset;
            seek_descriptor.whence = FSAL_SEEK_SET;

            return cache_inode_rdwr(pentry,
                                    CACHE_INODE_WRITE,
                                    &seek_descriptor,
                                    count,
                                    &size_io_done,
                                    pfsal_attr,
                                    (char *)(udata->buffer + offset - udata->offset),
                                    &eof, ht, pclient,
                                    pcontext, TRUE, pstatus);
    }
  /* Regulat exit */
  *pstatus = CACHE_INODE_SUCCESS;
  return *pstatus;
}
Exemplo n.º 20
0
BOOL CTraceTabBaseDlg::CreateAndPlaceDialogs()
{
    m_TabCtrl.ModifyStyle(m_TabStyleRemove, m_TabStyleAdd);

    size_t NumDlg = m_TabDlgVec.size();
    LONG Width = 0, Height = 0;
    for(size_t i = 0 ; i < NumDlg; ++i)
    {
        m_TabCtrl.InsertItem(m_TabDlgVec[i].DialogId , m_TabDlgVec[i].TabName);

        CDialog* pChild = m_TabDlgVec[i].Child;
        int DialogId = m_TabDlgVec[i].DialogId;
        if (!pChild->Create(DialogId, this))
        {
            LogEvent(LE_ERROR, "CTraceTabBaseDlg::CreateAndPlaceDialogs: Failed to build dialog. IDD = %d", DialogId);
            Assert(false);
            return FALSE;
        }
        CRect ChildRect;
        pChild->GetWindowRect(&ChildRect);
        Width = max(Width, ChildRect.right - ChildRect.left);
        Height = max(Height, ChildRect.bottom - ChildRect.top);
    }

    CRect TabWindowRect;
    m_TabCtrl.GetWindowRect(&TabWindowRect);
    LONG TabWidth = TabWindowRect.right - TabWindowRect.left;
    LONG TabHeight = TabWindowRect.bottom - TabWindowRect.top;
    Width = max(Width+10, TabWidth);
    Height = max(Height, TabHeight);
    TabWindowRect.right = TabWindowRect.left + Width;
    TabWindowRect.bottom = TabWindowRect.top + Height;
    LONG TabWindowLeft = TabWindowRect.left;
    LONG TabWindowTop = TabWindowRect.top;
    ScreenToClient(&TabWindowRect);
    m_TabCtrl.MoveWindow(TabWindowRect);
    //SetListBoxTopLeft(TabWindowRect.top + 5, 10+Width);
    //SetListBoxTopLeft(-1, 10+Width);
    SetListBoxTopLeft(-1, Width);

    LONG Left = MAXLONG, Top = 0;
    for(size_t i = 0 ; i < NumDlg; ++i)
	{
        CRect ItemRect;
        m_TabCtrl.GetItemRect(i, &ItemRect);
        Left = min(Left, ItemRect.left);
        Top = max(Top, ItemRect.bottom);
	}
    //Left += TabWindowLeft + 5;
    //Top += TabWindowTop + 5;
    Left += TabWindowLeft;
    Top += TabWindowTop + 2;
    for(size_t i = 0 ; i < NumDlg; ++i)
    {
        CDialog* pChild = m_TabDlgVec[i].Child;
        CRect ChildRect;
        pChild->GetWindowRect(&ChildRect);
        ChildRect.OffsetRect(Left - ChildRect.left, Top - ChildRect.top);
        ScreenToClient(ChildRect);
        pChild->MoveWindow(ChildRect);
    }

    if(!m_TabDlgVec.empty())
    {
        m_TabCtrl.SetCurSel(m_TabItem);
    }
    else
    {
        //no dialogs
        LogEvent(LE_INFO, "CTraceTabBaseDlg::CreateAndPlaceDialogs() No Dialogs so hide the Tab Control");
        m_TabCtrl.ShowWindow(SW_HIDE);
        SetListBoxTopLeft(-1, 8);
    }

    return TRUE;
}
Exemplo n.º 21
0
int CStreamMuxerImp1::CloseStream(void)
{
    HRESULT hr = S_OK;
    SSF_BUFFER outputBuffer;
    ZeroMemory(&outputBuffer, sizeof(outputBuffer));


    /////////Update the headers for each fMP4 file///////////////
    ///Video
    if(m_pVideoStream)
    {
        m_pVideoStream->FlushOutput();
        hr = SSFMuxGetHeader( m_hSSFMux, m_pVideoStream->GetStreamIndex(), 1, &outputBuffer );
        if( FAILED(hr) )
        {
            char buf[1024];
            sprintf_s(buf, "Error 0x%08x: Failed to get FMP4 header\n", hr );
            LogEvent(buf);
            return FALSE;
        }
        //////////////////////////////////////////////////

        hr = m_pVideoStream->WriteStreamToOutput( outputBuffer.pbBuffer, outputBuffer.cbBuffer, L"r+b");
        if( FAILED(hr) )
        {
            char buf[1024];
            sprintf_s(buf, "Error 0x%08x: WriteToSmoothStreamOutput\n", hr );
            LogEvent(buf);
            return FALSE;
        }
    }
    if(m_pAudioStream)
    {   ////Audio
        m_pAudioStream->FlushOutput();
        hr = SSFMuxGetHeader( m_hSSFMux, m_pAudioStream->GetStreamIndex(), 1, &outputBuffer );
        if( FAILED(hr) )
        {
            char buf[1024];
            sprintf_s(buf, "Error 0x%08x: Failed to get FMP4 header\n", hr );
            LogEvent(buf);
            return FALSE;
        }
        //////////////////////////////////////////////////
        hr = m_pAudioStream->WriteStreamToOutput( outputBuffer.pbBuffer, outputBuffer.cbBuffer, L"r+b");
        if( FAILED(hr) )
        {
            char buf[1024];
            sprintf_s(buf, "Error 0x%08x: WriteToSmoothStreamOutput\n", hr );
            LogEvent(buf);
            return FALSE;
        }
    }
    ///////////////////////
    int retval = 0;
    hr = SSFMuxGetIndex( m_hSSFMux,m_pVideoStream->GetStreamIndex(), 1, &outputBuffer );
    if( FAILED(hr) )
    {
        char buf[1024];
        sprintf_s(buf, "Error 0x%08x: Failed to get FMP4 index\n", hr );
        LogEvent(buf);
        retval = -1;
    }


    hr = m_pVideoStream->WriteStreamToOutput(
             outputBuffer.pbBuffer,
             outputBuffer.cbBuffer, L"ab");
    if( FAILED(hr) )
    {
        retval = -1;
    }

    if(m_pAudioStream)
    {
        hr = SSFMuxGetIndex( m_hSSFMux,m_pAudioStream->GetStreamIndex(), 1, &outputBuffer );
        if( FAILED(hr) )
        {
            char buf[1024];
            sprintf_s(buf, "Error 0x%08x: Failed to get Audio FMP4 index\n", hr );
            LogEvent(buf);
            retval = -1;
        }


        hr = m_pAudioStream->WriteStreamToOutput(
                 outputBuffer.pbBuffer,
                 outputBuffer.cbBuffer, L"ab");
        if( FAILED(hr) )
        {
            retval = -1;
        }
    }
    WriteManifests();
    return retval;
}
cache_inode_status_t
cache_inode_create(cache_entry_t *parent,
                   const char *name,
                   object_file_type_t type,
                   uint32_t mode,
                   cache_inode_create_arg_t *create_arg,
                   struct req_op_context *req_ctx,
                   cache_entry_t **entry)
{
     cache_inode_status_t status = CACHE_INODE_SUCCESS;
     fsal_status_t fsal_status = {0, 0};
     struct fsal_obj_handle *object_handle;
     struct attrlist object_attributes;
     struct fsal_obj_handle *dir_handle;
     cache_inode_create_arg_t zero_create_arg;
     fsal_accessflags_t access_mask = 0;

     memset(&zero_create_arg, 0, sizeof(zero_create_arg));
     memset(&object_attributes, 0, sizeof(object_attributes));

     if (create_arg == NULL) {
          create_arg = &zero_create_arg;
     }

     if ((type != REGULAR_FILE) && (type != DIRECTORY) &&
         (type != SYMBOLIC_LINK) && (type != SOCKET_FILE) &&
         (type != FIFO_FILE) && (type != CHARACTER_FILE) &&
         (type != BLOCK_FILE)) {
          status = CACHE_INODE_BAD_TYPE;

          *entry = NULL;
          goto out;
        }

    /*
     * Check if caller is allowed to perform the operation
     */
    access_mask = FSAL_MODE_MASK_SET(FSAL_W_OK) |
                  FSAL_ACE4_MASK_SET(FSAL_ACE_PERM_ADD_FILE |
                                     FSAL_ACE_PERM_ADD_SUBDIRECTORY);
    status = cache_inode_access(parent,
                                access_mask,
                                req_ctx);
    if (status != CACHE_INODE_SUCCESS)
        {
          *entry = NULL;
          goto out;
        }

    /* Try to create it first */

    dir_handle = parent->obj_handle;
/* we pass in attributes to the create.  We will get them back below */
    FSAL_SET_MASK(object_attributes.mask, ATTR_MODE|ATTR_OWNER|ATTR_GROUP);
    object_attributes.owner = req_ctx->creds->caller_uid;
    object_attributes.group = req_ctx->creds->caller_gid; /* be more selective? */
    object_attributes.mode = mode;

    switch (type) {
    case REGULAR_FILE:
            fsal_status = dir_handle->ops->create(dir_handle, req_ctx,
                                                  name,
                                                  &object_attributes,
                                                  &object_handle);
            break;

    case DIRECTORY:
            fsal_status = dir_handle->ops->mkdir(dir_handle, req_ctx,
                                                 name,
                                                 &object_attributes,
                                                 &object_handle);
            break;

    case SYMBOLIC_LINK:
            fsal_status = dir_handle->ops->symlink(dir_handle, req_ctx,
                                                   name,
                                                   create_arg->link_content,
                                                   &object_attributes,
                                                   &object_handle);
            break;

        case SOCKET_FILE:
        case FIFO_FILE:
            fsal_status = dir_handle->ops->mknode(dir_handle, req_ctx,
                                                  name,
                                                  type,
                                                  NULL, /* no dev_t needed */
                                                  &object_attributes,
                                                  &object_handle);
            break;

        case BLOCK_FILE:
        case CHARACTER_FILE:
            fsal_status = dir_handle->ops->mknode(dir_handle, req_ctx,
                                                  name,
                                                  type,
                                                  &create_arg->dev_spec,
                                                  &object_attributes,
                                                  &object_handle);
            break;

    default:
            /* we should never go there */
            status = CACHE_INODE_INCONSISTENT_ENTRY;
            *entry = NULL;
            goto out;
            break;
    }

     cache_inode_refresh_attrs_locked(parent, req_ctx);

     /* Check for the result */
     if (FSAL_IS_ERROR(fsal_status)) {
          if (fsal_status.major == ERR_FSAL_STALE) {
               LogEvent(COMPONENT_CACHE_INODE,
                        "FSAL returned STALE on create type %d", type);
               cache_inode_kill_entry(parent);
          } else if (fsal_status.major == ERR_FSAL_EXIST) {
               /* Already exists. Check if type if correct */
               status = cache_inode_lookup(parent,
                                           name,
                                           req_ctx,
                                           entry);
               if (*entry != NULL) {
                    status = CACHE_INODE_ENTRY_EXISTS;
                    if ((*entry)->type != type) {
                         /* Incompatible types, returns NULL */
                         cache_inode_put(*entry);
                         *entry = NULL;
                    }
                    goto out;
               }

               if (status == CACHE_INODE_NOT_FOUND) {
                    /* Too bad, FSAL insist the file exists when we try to
                     * create it, but lookup couldn't find it, retry. */
                    status = CACHE_INODE_INCONSISTENT_ENTRY;
                    goto out;
               }
          }

          status = cache_inode_error_convert(fsal_status);
          *entry = NULL;
          goto out;
     }
     status = cache_inode_new_entry(object_handle,
				    CACHE_INODE_FLAG_CREATE,
				    entry);
     if (*entry == NULL) {
          goto out;
     }

     PTHREAD_RWLOCK_wrlock(&parent->content_lock);
     /* Add this entry to the directory (also takes an internal ref) */
     status = cache_inode_add_cached_dirent(parent,
					    name,
					    *entry,
					    NULL);
     PTHREAD_RWLOCK_unlock(&parent->content_lock);
     if (status != CACHE_INODE_SUCCESS) {
          cache_inode_put(*entry);
          *entry = NULL;
          goto out;
     }

out:
     return status;
}
Exemplo n.º 23
0
void main(int argc,char *argv[]) {
  int x;
  long tid;
  char tellstr[100],*tmppscreen, titel[80], configname[50] = "NiKom:DatoCfg/SerNode.cfg";
  if(argc>1) for(x=1;x<argc;x++) {
      if(argv[x][0]=='-') {
        if(argv[x][1]=='B') dtespeed=atoi(&argv[x][2]);
        else if(argv[x][1]=='N') nodnr = atoi(&argv[x][2]);
      } else strcpy(configname,argv[x]);
    }
  if(nodnr==-1) {
    printf("NiKomSer måste startas från prenoden.\n");
    exit(10);
  }
  NewList((struct List *)&aliaslist);
  NewList((struct List *)&edit_list);
  if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0)))
    cleanup(EXIT_ERROR,"Kunde inte öppna intuition.library\n");
  if(!(UtilityBase=OpenLibrary("utility.library",37L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna utility.library\n");
  if(!(LocaleBase=OpenLibrary("locale.library",38L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna locale.library\n");
  if(!(NiKomBase=OpenLibrary("nikom.library",0L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna nikom.library\n");

  initnode(NODSPAWNED);
  if(!(nikomnodeport = CreateMsgPort()))
    cleanup(EXIT_ERROR,"Kunde inte skapa NiKomNode-porten");
  sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr);
  nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn;
  nikomnodeport->mp_Node.ln_Pri = 1;
  AddPort(nikomnodeport);
  sprintf(rexxportnamn,"NiKomRexx%d",nodnr);
  if(!(rexxport=(struct MsgPort *)CreateMsgPort()))
    cleanup(EXIT_ERROR,"Kunde inte öppna RexxPort\n");
  rexxport->mp_Node.ln_Name=rexxportnamn;
  rexxport->mp_Node.ln_Pri = 50;
  AddPort(rexxport);
  if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna rexxsyslib.library\n");
  getnodeconfig(configname);
  if(pubscreen[0]=='-') tmppscreen=NULL;
  else tmppscreen=pubscreen;
  if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos,
                                               WA_Top,ypos,
                                               WA_Width,xsize,
                                               WA_Height,ysize,
                                               WA_IDCMP,IDCMP_CLOSEWINDOW,
                                               WA_MinWidth,50,
                                               WA_MinHeight,10,
                                               WA_MaxWidth,~0,
                                               WA_MaxHeight,~0,
                                               WA_SizeGadget,TRUE,
                                               WA_SizeBBottom, TRUE,
                                               WA_DragBar,TRUE,
                                               WA_DepthGadget,TRUE,
                                               WA_CloseGadget,TRUE,
                                               WA_SimpleRefresh,TRUE,
                                               WA_ScreenTitle,"NiKomSer",
                                               WA_AutoAdjust,TRUE,
                                               WA_PubScreenName,tmppscreen,
                                               TAG_DONE)))
    cleanup(EXIT_ERROR,"Kunde inte öppna fönstret\n");
  if(!OpenIO(NiKwind)) cleanup(EXIT_ERROR,"Kunde inte öppna IO\n");
  inloggad=Servermem->inloggad[nodnr];
  conreqtkn();
  serreqtkn();
  UpdateInactive();
  sprintf(titel,"Nod #%d SER: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad);
  SetWindowTitles(NiKwind,titel,(char *)-1L);
  if(!ReadUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad)) {
    puttekn("Error reading unread text info.\r\n", -1);
    LogEvent(SYSTEM_LOG, ERROR,
             "Can't read unread text info for user %d", inloggad);
    cleanup(EXIT_ERROR, "Error reading unread text info.\n");
  }
  if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) {
    sendfile("NiKom:Texter/Bulletin.txt");
  }

  connection();

  if(nodestate & NIKSTATE_NOCARRIER) {
    conputtekn("\nCarrier dropped\n",-1);
    if(Servermem->cfg.logmask & LOG_CARDROPPED) {
      LogEvent(USAGE_LOG, WARN, "%s släpper carriern (nod %d)",
               getusername(inloggad), nodnr);
    }
    if(Servermem->cfg.ar.cardropped) sendautorexx(Servermem->cfg.ar.cardropped);
  } else {
    if(nodestate & NIKSTATE_AUTOLOGOUT) {
      puttekn("\n\n\r*** Automagisk utloggning ***\n\n\r",-1);
    } else if(nodestate & NIKSTATE_INACTIVITY) {
      puttekn("\n\n\r*** Utloggning p.g.a inaktivitet ***\n\n\r",-1);
    }
    radcnt=-174711;
    if(Servermem->say[nodnr]) displaysay();
    if(Servermem->cfg.ar.utlogg) sendautorexx(Servermem->cfg.ar.utlogg);
    sendfile("NiKom:Texter/Utlogg.txt");
  }
  Servermem->inloggad[nodnr]=-1;
  if(Servermem->cfg.logmask & LOG_UTLOGG) {
    LogEvent(USAGE_LOG, INFO, "%s loggar ut från nod %d",
             getusername(inloggad), nodnr);
  }
  Servermem->action[nodnr]=0;
  time(&tid);
  Servermem->inne[nodnr].senast_in=tid;
  Servermem->inne[nodnr].tot_tid+=(tid-logintime);
  Servermem->inne[nodnr].loggin++;
  Servermem->info.inloggningar++;
  Servermem->inne[nodnr].defarea=area2;
  writeuser(inloggad,&Servermem->inne[nodnr]);
  WriteUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad);
  writesenaste();
  AbortInactive();
  freealiasmem();
  sprintf(tellstr,"loggade just ut från nod %d",nodnr);
  tellallnodes(tellstr);

  if(nodestate & NIKSTATE_NOCARRIER) {
    nodestate &= ~NIKSTATE_RELOGIN;
  }
  nodestate &= (NIKSTATE_RELOGIN | NIKSTATE_CLOSESER | NIKSTATE_NOANSWER);
  cleanup(nodestate,"");
}
Exemplo n.º 24
0
void main(int argc, char **argv) {
  int going = TRUE, forsok = 2,car = 1, tmp, ch;
  long tid;
  char tellstr[100],*tmppscreen, titel[80];

  NewList((struct List *)&aliaslist);
  NewList((struct List *)&edit_list);
  if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0)))
    cleanup(EXIT_ERROR,"Kunde inte öppna intuition.library\n");
  if(!(UtilityBase=OpenLibrary("utility.library",37L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna utility.library\n");
  if(!(LocaleBase=OpenLibrary("locale.library",38L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna locale.library\n");
  if(!(NiKomBase=OpenLibrary("nikom.library",0L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna nikom.linbrary");
  getnodeconfig("NiKom:Datocfg/ConNode.cfg");
  if(!(initnode(NODCON))) cleanup(EXIT_ERROR,"Kunde inte registrera noden i Servern\n");
  if(!(nikomnodeport = CreateMsgPort()))
    cleanup(EXIT_ERROR,"Kunde inte skapa NiKomNode-porten");
  sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr);
  nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn;
  nikomnodeport->mp_Node.ln_Pri = 1;
  AddPort(nikomnodeport);
  sprintf(rexxportnamn,"NiKomRexx%d",nodnr);
  if(!(rexxport=(struct MsgPort *)CreateMsgPort()))
    cleanup(EXIT_ERROR,"Kunde inte öppna RexxPort\n");
  rexxport->mp_Node.ln_Name=rexxportnamn;
  rexxport->mp_Node.ln_Pri=50;
  AddPort(rexxport);
  if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L)))
    cleanup(EXIT_ERROR,"Kunde inte öppna rexxsyslib.library\n");
  if(pubscreen[0]=='-') tmppscreen=NULL;
  else tmppscreen=pubscreen;
  if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos,
                                               WA_Top,ypos,
                                               WA_Width,xsize,
                                               WA_Height,ysize,
                                               WA_IDCMP,IDCMP_CLOSEWINDOW,
                                               WA_MinWidth,50,
                                               WA_MinHeight,10,
                                               WA_MaxWidth,~0,
                                               WA_MaxHeight,~0,
                                               WA_SizeGadget,TRUE,
                                               WA_SizeBBottom, TRUE,
                                               WA_DragBar,TRUE,
                                               WA_DepthGadget,TRUE,
                                               WA_CloseGadget,TRUE,
                                               WA_SimpleRefresh,TRUE,
                                               WA_ScreenTitle,"NiKomCon",
                                               WA_AutoAdjust,TRUE,
                                               WA_PubScreenName,tmppscreen,
                                               TAG_DONE)))
    cleanup(EXIT_ERROR,"Kunde inte öppna fönstret\n");
  if(!OpenIO(NiKwind)) cleanup(EXIT_ERROR,"Kunde inte öppna IO\n");
  strcpy(Servermem->nodid[nodnr],nodid);
  sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr);
  SetWindowTitles(NiKwind,titel,(UBYTE *)-1L);
  Servermem->connectbps[nodnr] = -1;
  conreqtkn();
  do {
    Servermem->idletime[nodnr] = time(NULL);
    memset(commandhistory,0,1024);
    Servermem->inne[nodnr].rader=0;
    sendfile("NiKom:Texter/Inlogg.txt");
    if(Servermem->cfg.ar.preinlogg) sendautorexx(Servermem->cfg.ar.preinlogg);
    going=TRUE;
    while(going) {
      Servermem->idletime[nodnr] = time(NULL);
      puttekn("\r\nNamn: ",-1);
      getstring(EKO,40,NULL);
      if(!stricmp(inmat,Servermem->cfg.ny)) {
        tmp = RegisterNewUser();
        if(tmp == 2) {
          goto panik;
        }
        car = tmp ? 0 : 1;
        going=FALSE;
      }
      else if((inloggad=parsenamn(inmat))>=0) {
        if(readuser(inloggad,&Servermem->inne[nodnr])) {
          puttekn("Error reading user data.\r\n", -1);
          goto panik;
        }
        // TODO: Extract password loop. Should be identical to in PreNode/Ser.c
        forsok=2;
        while(forsok) {
          puttekn("\r\nLösen: ",-1);
          if(Servermem->inne[nodnr].flaggor & STAREKOFLAG)
            getstring(STAREKO,15,NULL);
          else
            getstring(EJEKO,15,NULL);
          if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) {
            forsok=FALSE;
            going=FALSE;
          } else {
            forsok--;
          }
        }
      } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1);
    }
    sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad);
    SetWindowTitles(NiKwind,titel,(UBYTE *)-1L);
    if(!ReadUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad)) {
      puttekn("Error reading unread text info.\r\n", -1);
      LogEvent(SYSTEM_LOG, ERROR,
               "Can't read unread text info for user %d", inloggad);
      goto panik;
    }
    Servermem->inloggad[nodnr]=inloggad;
    Servermem->idletime[nodnr] = time(NULL);
    if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt");

    connection();

    if(Servermem->cfg.logmask & LOG_UTLOGG) {
      LogEvent(USAGE_LOG, INFO, "%s loggar ut från nod %d",
               getusername(inloggad), nodnr);
    }
    if(Servermem->say[nodnr]) displaysay();
    if(Servermem->cfg.ar.utlogg) sendautorexx(Servermem->cfg.ar.utlogg);
    sendfile("NiKom:Texter/Utlogg.txt");
    sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr);
    SetWindowTitles(NiKwind,titel,(UBYTE *)-1L);
    Servermem->inloggad[nodnr]=-1;
    
    Servermem->action[nodnr]=0;
    time(&tid);
    Servermem->inne[nodnr].senast_in=tid;
    Servermem->inne[nodnr].tot_tid+=(tid-logintime);
    Servermem->inne[nodnr].loggin++;
    Servermem->info.inloggningar++;
    Servermem->inne[nodnr].defarea=area2;
    writeuser(inloggad,&Servermem->inne[nodnr]);
    WriteUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad);
    writesenaste();
    freealiasmem();
    sprintf(tellstr,"loggade just ut från nod %d",nodnr);
    tellallnodes(tellstr);
  panik:
    nodestate = 0;
    puttekn("\r\n\nEn inloggning till? (J/n)",-1);
  } while((ch = GetChar()) != 'n' && ch != 'N');
  cleanup(EXIT_OK,"");
}
Exemplo n.º 25
0
/**
 * _9p_dispatcher_thread: thread used for RPC dispatching.
 *
 * This function is the main loop for the 9p dispatcher.
 * It never returns because it is an infinite loop.
 *
 * @param Arg (unused)
 *
 * @return Pointer to the result (but this function will mostly loop forever).
 *
 */
void *_9p_dispatcher_thread(void *Arg)
{
	int _9p_socket;
	int rc = 0;
	long int newsock = -1;
	pthread_attr_t attr_thr;
	pthread_t tcp_thrid;

	SetNameFunction("_9p_disp");

	/* Calling dispatcher main loop */
	LogInfo(COMPONENT_9P_DISPATCH, "Entering nfs/rpc dispatcher");

	LogDebug(COMPONENT_9P_DISPATCH, "My pthread id is %p",
		 (caddr_t) pthread_self());

	/* Set up the _9p_socket (trying V6 first, will fall back to V4
	 * if V6 fails).
	 */
	_9p_socket = _9p_create_socket_V6();

	if (_9p_socket == -1) {
		LogFatal(COMPONENT_9P_DISPATCH,
			 "Can't get socket for 9p dispatcher");
	}

	/* Init for thread parameter (mostly for scheduling) */
	if (pthread_attr_init(&attr_thr) != 0)
		LogDebug(COMPONENT_9P_DISPATCH,
			 "can't init pthread's attributes");

	if (pthread_attr_setscope(&attr_thr, PTHREAD_SCOPE_SYSTEM) != 0)
		LogDebug(COMPONENT_9P_DISPATCH, "can't set pthread's scope");

	if (pthread_attr_setdetachstate(&attr_thr,
					PTHREAD_CREATE_DETACHED) != 0)
		LogDebug(COMPONENT_9P_DISPATCH,
			 "can't set pthread's join state");

	LogEvent(COMPONENT_9P_DISPATCH, "9P dispatcher started");

	while (true) {
		newsock = accept(_9p_socket, NULL, NULL);

		if (newsock < 0) {
			LogCrit(COMPONENT_9P_DISPATCH, "accept failed: %d",
				errno);
			continue;
		}

		/* Starting the thread dedicated to signal handling */
		rc = pthread_create(&tcp_thrid, &attr_thr,
				    _9p_socket_thread, (void *)newsock);
		if (rc != 0) {
			LogFatal(COMPONENT_THREAD,
				 "Could not create 9p socket manager thread, error = %d (%s)",
				 errno, strerror(errno));
		}
	}			/* while */

	close(_9p_socket);

	return NULL;
}				/* _9p_dispatcher_thread */
void *file_content_gc_thread(void *IndexArg)
{
  char command[2 * MAXPATHLEN];
  exportlist_t *pexport = NULL;
  int is_hw_reached = FALSE;
  int some_flush_to_do = FALSE;
  unsigned long nb_blocks_to_manage;
  char cache_sub_dir[MAXPATHLEN];
  cache_content_status_t cache_content_status;
  FILE *command_stream = NULL;

  char logfile_arg[MAXPATHLEN];
  char *loglevel_arg;

  SetNameFunction("file_content_gc_thread");

  LogEvent(COMPONENT_MAIN,
           "NFS FILE CONTENT GARBAGE COLLECTION : Starting GC thread");

  if(mark_thread_existing(&gccb) == PAUSE_EXIT)
    {
      /* Oops, that didn't last long... exit. */
      mark_thread_done(&gccb);
      LogDebug(COMPONENT_DISPATCH,
               "NFS FILE CONTENT GARBAGE COLLECTION Thread exiting before initialization");
      return NULL;
    }

  LogDebug(COMPONENT_MAIN,
           "NFS FILE CONTENT GARBAGE COLLECTION : my pthread id is %p",
           (caddr_t) pthread_self());

  while(1)
    {
      /* Sleep until some work is to be done */
      sleep(nfs_param.cache_layers_param.dcgcpol.run_interval);

      if(gccb.tcb_state != STATE_AWAKE)
        {
          while(1)
            {
              P(gccb.tcb_mutex);
              if(gccb.tcb_state == STATE_AWAKE)
                {
                  V(gccb.tcb_mutex);
                  break;
                }
              switch(thread_sm_locked(&gccb))
                {
                  case THREAD_SM_RECHECK:
                    V(gccb.tcb_mutex);
                    continue;

                  case THREAD_SM_BREAK:
                    V(gccb.tcb_mutex);
                    break;

                  case THREAD_SM_EXIT:
                    V(gccb.tcb_mutex);
                    return NULL;
                }
            }
        }

      LogEvent(COMPONENT_MAIN,
               "NFS FILE CONTENT GARBAGE COLLECTION : processing...");
      for(pexport = nfs_param.pexportlist; pexport != NULL; pexport = pexport->next)
        {
          if(pexport->options & EXPORT_OPTION_USE_DATACACHE)
            {
              snprintf(cache_sub_dir, MAXPATHLEN, "%s/export_id=%d",
                       nfs_param.cache_layers_param.cache_content_client_param.cache_dir,
                       0);

              if((cache_content_status = cache_content_check_threshold(cache_sub_dir,
                                                                       nfs_param.
                                                                       cache_layers_param.
                                                                       dcgcpol.lwmark_df,
                                                                       nfs_param.
                                                                       cache_layers_param.
                                                                       dcgcpol.hwmark_df,
                                                                       &is_hw_reached,
                                                                       &nb_blocks_to_manage))
                 == CACHE_CONTENT_SUCCESS)
                {
                  if(is_hw_reached)
                    {
                      LogEvent(COMPONENT_MAIN,
                               "NFS FILE CONTENT GARBAGE COLLECTION : High Water Mark is  reached, %lu blocks to be removed",
                               nb_blocks_to_manage);
                      some_flush_to_do = TRUE;
                      break;
                    }
                  else {
                    LogEvent(COMPONENT_MAIN,
                             "NFS FILE CONTENT GARBAGE COLLECTION : High Water Mark is not reached");
		  }

                  /* Use signal management */
                  if(force_flush_by_signal == TRUE)
                    {
                      some_flush_to_do = TRUE;
                      break;
                    }
                }
            }
        }                       /* for */

      if (strncmp(fcc_log_path, "/dev/null", 9) == 0)
	switch(LogComponents[COMPONENT_CACHE_INODE_GC].comp_log_type)
	  {
	  case FILELOG:
	    strncpy(logfile_arg, LogComponents[COMPONENT_CACHE_INODE_GC].comp_log_file, MAXPATHLEN);
	    break;
	  case SYSLOG:
	    strncpy(logfile_arg, "SYSLOG", MAXPATHLEN);
	    break;
	  case STDERRLOG:
	    strncpy(logfile_arg, "STDERRLOG", MAXPATHLEN);
	    break;
	  case STDOUTLOG:
	    strncpy(logfile_arg, "STDOUTLOG", MAXPATHLEN);
	    break;
	  default:
	    LogCrit(COMPONENT_MAIN,
	            "Could not figure out the proper -L option for emergency cache flush thread.");
	  }
      else
	strncpy(logfile_arg, fcc_log_path, MAXPATHLEN); /* config variable */

      if(fcc_debug_level != -1) /* config variable */
	loglevel_arg = ReturnLevelInt(fcc_debug_level);
      else
	loglevel_arg = ReturnLevelInt(ReturnLevelComponent(COMPONENT_CACHE_INODE_GC));

      snprintf(command, 2 * MAXPATHLEN, "%s -f %s -N %s -L %s",
	       ganesha_exec_path, config_path, loglevel_arg, logfile_arg);
	       
      if(some_flush_to_do)
        strncat(command, " -P 3", 2 * MAXPATHLEN);      /* Sync and erase */
      else
        strncat(command, " -S 3", 2 * MAXPATHLEN);      /* Sync Only */

      if((command_stream = popen(command, "r")) == NULL)
        LogCrit(COMPONENT_MAIN,
                "NFS FILE CONTENT GARBAGE COLLECTION : /!\\ Cannot lauch command %s",
                command);
      else
        LogEvent(COMPONENT_MAIN,
                 "NFS FILE CONTENT GARBAGE COLLECTION : I launched command %s",
                 command);

      pclose(command_stream);
    }
  tcb_remove(&gccb);
}                               /* file_content_gc_thread */
Exemplo n.º 27
0
/**
 *
 * cache_inode_getattr: Gets the attributes for a cached entry.
 *
 * Gets the attributes for a cached entry. The FSAL attributes are kept in a structure when the entry
 * is added to the cache.
 *
 * @param pentry [IN] entry to be managed.
 * @param pattr [OUT] pointer to the results
 * @param ht [IN] hash table used for the cache, unused in this call.
 * @param pclient [INOUT] ressource allocated by the client for the nfs management.
 * @param pcontext [IN] FSAL credentials
 * @param pstatus [OUT] returned status.
 *
 * @return CACHE_INODE_SUCCESS if operation is a success \n
 * @return CACHE_INODE_LRU_ERROR if allocation error occured when validating the entry
 *
 */
cache_inode_status_t
cache_inode_getattr(cache_entry_t * pentry,
                    fsal_attrib_list_t * pattr,
                    hash_table_t * ht, /* Unused, kept for protototype's homogeneity */
                    cache_inode_client_t * pclient,
                    fsal_op_context_t * pcontext,
                    cache_inode_status_t * pstatus)
{
    cache_inode_status_t status;
    fsal_handle_t *pfsal_handle = NULL;
    fsal_status_t fsal_status;

    /* sanity check */
    if(pentry == NULL || pattr == NULL ||
       ht == NULL || pclient == NULL || pcontext == NULL)
        {
            *pstatus = CACHE_INODE_INVALID_ARGUMENT;
            LogDebug(COMPONENT_CACHE_INODE,
                     "cache_inode_getattr: returning CACHE_INODE_INVALID_ARGUMENT because of bad arg");
            return *pstatus;
        }

    /* Set the return default to CACHE_INODE_SUCCESS */
    *pstatus = CACHE_INODE_SUCCESS;

    /* stats */
    pclient->stat.nb_call_total += 1;
    inc_func_call(pclient, CACHE_INODE_GETATTR);

    /* Lock the entry */
    P_w(&pentry->lock);
    status = cache_inode_renew_entry(pentry, pattr, ht,
                                     pclient, pcontext, pstatus);
    if(status != CACHE_INODE_SUCCESS)
        {
            V_w(&pentry->lock);
            inc_func_err_retryable(pclient, CACHE_INODE_GETATTR);
            LogFullDebug(COMPONENT_CACHE_INODE,
                         "cache_inode_getattr: returning %d(%s) from cache_inode_renew_entry",
                         *pstatus, cache_inode_err_str(*pstatus));
            return *pstatus;
        }

    /* RW Lock goes for writer to reader */
    rw_lock_downgrade(&pentry->lock);

    cache_inode_get_attributes(pentry, pattr);

    if(FSAL_TEST_MASK(pattr->asked_attributes,
                      FSAL_ATTR_RDATTR_ERR))
        {
            switch (pentry->internal_md.type)
                {
                case REGULAR_FILE:
                    pfsal_handle = &pentry->object.file.handle;
                    break;

                case SYMBOLIC_LINK:
                    assert(pentry->object.symlink);
                    pfsal_handle = &pentry->object.symlink->handle;
                    break;

                case DIRECTORY:
                    pfsal_handle = &pentry->object.dir.handle;
                    break;
                case SOCKET_FILE:
                case FIFO_FILE:
                case BLOCK_FILE:
                case CHARACTER_FILE:
                    pfsal_handle = &pentry->object.special_obj.handle;
                    break;
                case FS_JUNCTION:
                case UNASSIGNED:
                case RECYCLED:
                    *pstatus = CACHE_INODE_INVALID_ARGUMENT;
                    LogFullDebug(COMPONENT_CACHE_INODE,
                                 "cache_inode_getattr: returning %d(%s) from cache_inode_renew_entry - unexpected md_type",
                                 *pstatus, cache_inode_err_str(*pstatus));
                    return *pstatus;
                }

            /*
             * An error occured when trying to get
             * the attributes, they have to be renewed
             */
#ifdef _USE_MFSL
            fsal_status = FSAL_getattrs_descriptor(&(cache_inode_fd(pentry)->fsal_file), pfsal_handle, pcontext, pattr);
#else
            fsal_status = FSAL_getattrs_descriptor(cache_inode_fd(pentry), pfsal_handle, pcontext, pattr);
#endif
            if(FSAL_IS_ERROR(fsal_status))
                {
                    *pstatus = cache_inode_error_convert(fsal_status);
                    
                    V_r(&pentry->lock);

                    if(fsal_status.major == ERR_FSAL_STALE)
                        {
                            cache_inode_status_t kill_status;

                            LogEvent(COMPONENT_CACHE_INODE,
                                     "cache_inode_getattr: Stale FSAL File Handle detected for pentry = %p",
                                     pentry);

                            /* Locked flag is set to true to show entry has a read lock */
                            cache_inode_kill_entry( pentry, WT_LOCK, ht,
                                                    pclient, &kill_status);
                            if(kill_status != CACHE_INODE_SUCCESS)
                                LogCrit(COMPONENT_CACHE_INODE,
                                        "cache_inode_getattr: Could not kill entry %p, status = %u",
                                        pentry, kill_status);

                            *pstatus = CACHE_INODE_FSAL_ESTALE;
                        }

                    /* stat */
                    inc_func_err_unrecover(pclient, CACHE_INODE_GETATTR);
                    LogDebug(COMPONENT_CACHE_INODE,
                             "cache_inode_getattr: returning %d(%s) from FSAL_getattrs_descriptor",
                             *pstatus, cache_inode_err_str(*pstatus));
                    return *pstatus;
                }

            /* Set the new attributes */
            cache_inode_set_attributes(pentry, pattr);
        }
    *pstatus = cache_inode_valid(pentry, CACHE_INODE_OP_GET, pclient);

    V_r(&pentry->lock);

    /* stat */
    if(*pstatus != CACHE_INODE_SUCCESS)
        inc_func_err_retryable(pclient, CACHE_INODE_GETATTR);
    else
        inc_func_success(pclient, CACHE_INODE_GETATTR);

#ifdef _USE_NFS4_ACL
    if(isDebug(COMPONENT_NFS_V4_ACL))
      {
        LogDebug(COMPONENT_CACHE_INODE,
                 "cache_inode_getattr: pentry = %p, acl = %p",
                 pentry, pattr->acl);

        if(pattr->acl)
          {
            fsal_ace_t *pace;
            for(pace = pattr->acl->aces; pace < pattr->acl->aces + pattr->acl->naces; pace++)
              {
                LogDebug(COMPONENT_CACHE_INODE,
                         "cache_inode_getattr: ace type = 0x%x, flag = 0x%x, perm = 0x%x, special = %d, %s = 0x%x",
                         pace->type, pace->flag, pace->perm, IS_FSAL_ACE_SPECIAL_ID(*pace),
                         GET_FSAL_ACE_WHO_TYPE(*pace), GET_FSAL_ACE_WHO(*pace));
              }
          }
      }
#endif                          /* _USE_NFS4_ACL */

    LogFullDebug(COMPONENT_CACHE_INODE,
                 "cache_inode_getattr: returning %d(%s) from cache_inode_valid",
                 *pstatus, cache_inode_err_str(*pstatus));
    return *pstatus;
}
Exemplo n.º 28
0
/**
 * @brief Copy file content.
 *
 * @param[in]     src_entry    File to copy from
 * @param[in]     src_offset   Offset start from the source file
 * @param[in]     dst_entry    Destination file to copy to
 * @param[in]     dst_offset   Offset in the dest file
 * @param[out]    count	       Requested bytes to copy
 * @param[out]    copied       Bytes successfully copied
 *
 * @return CACHE_INODE_SUCCESS or various errors
 */
cache_inode_status_t cache_inode_copy(cache_entry_t *src_entry,
				      uint64_t src_offset,
				      cache_entry_t *dst_entry,
				      uint64_t dst_offset, uint64_t count,
				      uint64_t *copied)
{
	fsal_status_t fsal_status = { 0, 0 };
	cache_inode_status_t status;

	/**
	 * To avoid deadlock, we always lock the entry with a smaller address
	 * before the locking the other entry.  Note that "content_lock"
	 * protects "cache content" instead of file content.  So only reader
	 * lock is needed for either file.
	 */
	if ((size_t)src_entry < (size_t)dst_entry) {
		PTHREAD_RWLOCK_rdlock(&src_entry->content_lock);
		PTHREAD_RWLOCK_rdlock(&dst_entry->content_lock);
	} else {
		PTHREAD_RWLOCK_rdlock(&dst_entry->content_lock);
		PTHREAD_RWLOCK_rdlock(&src_entry->content_lock);
	}

	if (!is_open(src_entry) || !is_open(dst_entry)) {
		LogEvent(COMPONENT_CACHE_INODE,
			 "Cannot copy between files that are not open");
		status = NFS4ERR_OPENMODE;
		goto out;
	}

	if (count == UINT64_MAX) {
		count = src_entry->obj_handle->attrs->filesize - src_offset;
		LogDebug(COMPONENT_CACHE_INODE,
			 "0-count has an effective value of %zu", count);
	}

	fsal_status = src_entry->obj_handle->obj_ops.copy(src_entry->obj_handle,
							  src_offset,
							  dst_entry->obj_handle,
							  dst_offset,
							  count,
							  copied);

	if (FSAL_IS_ERROR(fsal_status)) {
		*copied = 0;
		status = cache_inode_error_convert(fsal_status);
		LogEvent(COMPONENT_CACHE_INODE,
			 "File copy failed: major = %d, minor = %d",
			 fsal_status.major, fsal_status.minor);
		goto out;
	}

	/* Update dest file after coping to it. */
	PTHREAD_RWLOCK_wrlock(&dst_entry->attr_lock);
	status = cache_inode_refresh_attrs(dst_entry);
	PTHREAD_RWLOCK_unlock(&dst_entry->attr_lock);

out:
	if ((size_t)src_entry < (size_t)dst_entry) {
		PTHREAD_RWLOCK_unlock(&dst_entry->content_lock);
		PTHREAD_RWLOCK_unlock(&src_entry->content_lock);
	} else {
		PTHREAD_RWLOCK_unlock(&src_entry->content_lock);
		PTHREAD_RWLOCK_unlock(&dst_entry->content_lock);
	}

	return status;
}
Exemplo n.º 29
0
BOOL DoServiceInitialize( DWORD dwArgc, LPTSTR *lpszArgv )
{
    int     iIndex, iLast;
    char    szModel[65];

    // Open Log File

    if( !OpenLog() )
        return( FALSE );

    LogEvent( LOG_LEVEL_INFO, "Service Loading; Version = " PROGRAM_VERSION_STR );

    // Enumerate Temperature Sensors

    iVtmTemps = InitVtmUpdate();

    if( iVtmTemps < 0 )
    {
        LogEvent( LOG_LEVEL_ERROR, "Unable to ascertain VTM count; ccode = %d", GetLastError() );
        LogEvent( LOG_LEVEL_INFO,  "Service Terminated" );
        return( FALSE );
    }

    // No need to continue if no VTMs configured for HD monitoring...

    if( iVtmTemps == 0 )
    {
        LogEvent( LOG_LEVEL_INFO,  "No VTMs configured for HD monitoring" );
        LogEvent( LOG_LEVEL_INFO,  "Service Terminated" );
        DoneVtmUpdate();
        return( FALSE );
    }

    LogEvent( LOG_LEVEL_INFO, "Servicing %d VTMs", iVtmTemps );

    // Initialize S.M.A.R.T. Support

    iSmartTemps = InitSmartTemp();

    if( iSmartTemps == NO_RESULT_AVAIL )
    {
        LogEvent( LOG_LEVEL_ERROR, "Cannot initialize S.M.A.R.T. access; ccode = %d", GetLastError() );
        LogEvent( LOG_LEVEL_INFO,  "Service Terminated" );
        DoneVtmUpdate();
        return( FALSE );
    }

    LogEvent( LOG_LEVEL_INFO, "Servicing %d HDDs", iSmartTemps );

    // Document monitor-drive associations

    iLast = ( iVtmTemps > iSmartTemps )? iVtmTemps : iSmartTemps;

    for( iIndex = 0; iIndex < iLast; iIndex++ )
    {
        GetSmartModel( iIndex, szModel );
        LogEvent( LOG_LEVEL_INFO, "VTM %d (TM %d) receiving temperatures from HDD %d (%s)",
                  iIndex + 1, GetVtmIndex( iIndex ) + 1, GetSmartIndex( iIndex ) + 1, szModel );
    }

    return( TRUE );
}
Exemplo n.º 30
0
void Logger::LogStartEvent(const NMEA_INFO &gps_info) {
  LogEvent(gps_info, "STA");
}