2 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * This file is part of <starter>
5 * Written by <Seungtaek Chung> <seungtaek.chung@samsung.com>, <Mi-Ju Lee> <miju52.lee@samsung.com>, <Xi Zhichan> <zhichan.xi@samsung.com>
7 * PROPRIETARY/CONFIDENTIAL
9 * This software is the confidential and proprietary information of SAMSUNG ELECTRONICS ("Confidential Information").
10 * You shall not disclose such Confidential Information and shall use it only in accordance
11 * with the terms of the license agreement you entered into with SAMSUNG ELECTRONICS.
12 * SAMSUNG make no representations or warranties about the suitability of the software,
13 * either express or implied, including but not limited to the implied warranties of merchantability,
14 * fitness for a particular purpose, or non-infringement.
15 * SAMSUNG shall not be liable for any damages suffered by licensee as a result of using,
16 * modifying or distributing this software or its derivatives.
29 #include "lockd-debug.h"
32 #define MAXFILELEN 1048576
33 #define LOGFILE "/tmp/starter.log"
35 void lockd_log_t(char *fmt, ...)
39 char buf[LINEMAX] = { 0, };
40 char debugString[LINEMAX] = { 0, };
43 vsnprintf(buf, sizeof(buf), fmt, ap);
47 time_t current_time = 0;
48 bzero((char *)&debugString, LINEMAX);
50 gmtime_r(¤t_time, &local_t);
51 int len = snprintf(debugString, sizeof(debugString),
52 "[%d-%02d-%02d, %02d:%02d:%02d]: ",
53 local_t.tm_year + 1900, local_t.tm_mon + 1,
54 local_t.tm_mday, local_t.tm_hour, local_t.tm_min,
59 debugString[len] = '\0';
61 len = g_strlcat(debugString, buf, LINEMAX);
65 debugString[len] = '\n';
67 if ((fd = fopen(LOGFILE, "at+")) == NULL) {
68 LOCKD_DBG("File fopen fail for writing Pwlock information");
71 if (fwrite(debugString, strlen(debugString), 1, fd) < 1) {
73 ("File fwrite fail for writing Pwlock information");
75 if ((pid = fork()) < 0) {
76 } else if (pid == 0) {
77 execl("/bin/rm", "rm", "-f", LOGFILE,
81 fseek(fd, 0l, SEEK_END);
83 if (fileLen > MAXFILELEN) {
85 if ((pid = fork()) < 0) {
87 } else if (pid == 0) {
88 execl("/bin/rm", "rm", "-f", LOGFILE,