[launchd-changes] [23851] branches/PR-6564965/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 2 14:45:26 PST 2009
Revision: 23851
http://trac.macosforge.org/projects/launchd/changeset/23851
Author: dsorresso at apple.com
Date: 2009-03-02 14:45:26 -0800 (Mon, 02 Mar 2009)
Log Message:
-----------
More generalization of the job databases.
Modified Paths:
--------------
branches/PR-6564965/launchd/src/launchctl.c
branches/PR-6564965/launchd/src/launchd.c
branches/PR-6564965/launchd/src/launchd.h
branches/PR-6564965/launchd/src/launchd_core_logic.c
branches/PR-6564965/launchd/src/vproc_priv.h
Modified: branches/PR-6564965/launchd/src/launchctl.c
===================================================================
--- branches/PR-6564965/launchd/src/launchctl.c 2009-02-28 21:16:59 UTC (rev 23850)
+++ branches/PR-6564965/launchd/src/launchctl.c 2009-03-02 22:45:26 UTC (rev 23851)
@@ -262,8 +262,14 @@
static bool g_job_overrides_db_has_changed = false;
static CFMutableDictionaryRef g_job_overrides_db = NULL;
-char g_job_overrides_db_path[PATH_MAX];
+static char g_job_overrides_db_path[PATH_MAX];
+#if 0
+static bool g_job_cache_db_has_changed = false;
+static launch_data_t g_job_cache_db = NULL;
+#endif
+static char g_job_cache_db_path[PATH_MAX];
+
int
main(int argc, char *const argv[])
{
@@ -344,7 +350,7 @@
char *db = NULL;
vproc_err_t verr = vproc_swap_string(NULL, VPROC_GSK_JOB_OVERRIDES_DB, NULL, &db);
if( verr ) {
- fprintf(stderr, "Could not get location of job state database.\n");
+ fprintf(stderr, "Could not get location of job overrides database.\n");
g_job_overrides_db_path[0] = 0;
} else {
strncpy(g_job_overrides_db_path, db, strlen(db));
@@ -356,6 +362,17 @@
}
}
+ verr = vproc_swap_string(NULL, VPROC_GSK_JOB_CACHE_DB, NULL, &db);
+ if( verr ) {
+ fprintf(stderr, "Could not get location of job cache database.\n");
+ g_job_cache_db_path[0] = 0;
+ } else {
+ strncpy(g_job_cache_db_path, db, strlen(db));
+ free(db);
+
+ /* Create our launch_data_t from the file... */
+ }
+
if (NULL == readline) {
fprintf(stderr, "missing library: readline\n");
exit(EXIT_FAILURE);
Modified: branches/PR-6564965/launchd/src/launchd.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd.c 2009-02-28 21:16:59 UTC (rev 23850)
+++ branches/PR-6564965/launchd/src/launchd.c 2009-03-02 22:45:26 UTC (rev 23851)
@@ -117,7 +117,7 @@
bool fake_shutdown_in_progress;
bool network_up;
char g_username[128] = "__Uninitialized__";
-char g_job_overrides_db_path[PATH_MAX];
+char g_launchd_database_dir[PATH_MAX];
FILE *g_console = NULL;
int
@@ -189,7 +189,7 @@
strlcpy(g_username, pwent->pw_name, sizeof(g_username) - 1);
}
- snprintf(g_job_overrides_db_path, sizeof(g_job_overrides_db_path), LAUNCHD_DB_PREFIX "/com.apple.launchd.peruser.%u/overrides.plist", getuid());
+ snprintf(g_launchd_database_dir, sizeof(g_launchd_database_dir), LAUNCHD_DB_PREFIX "/com.apple.launchd.peruser.%u", getuid());
runtime_syslog(LOG_DEBUG, "Per-user launchd for UID %u (%s) has begun.", getuid(), g_username);
}
@@ -404,9 +404,34 @@
launchd_assumes(chdir("/") != -1);
launchd_assumes(setlogin("root") != -1);
- strcpy(g_job_overrides_db_path, LAUNCHD_DB_PREFIX "/com.apple.launchd/overrides.plist");
+ strcpy(g_launchd_database_dir, LAUNCHD_DB_PREFIX "/com.apple.launchd");
}
+char *
+launchd_data_base_path(int db_type)
+{
+ static char result[PATH_MAX];
+ static int last_db_type = -1;
+
+ if( db_type == last_db_type ) {
+ return result;
+ }
+
+ switch( db_type ) {
+ case LAUNCHD_DB_TYPE_OVERRIDES :
+ snprintf(result, sizeof(result), "%s/%s", g_launchd_database_dir, "overrides.plist");
+ last_db_type = db_type;
+ break;
+ case LAUNCHD_DB_TYPE_JOBCACHE :
+ snprintf(result, sizeof(result), "%s/%s", g_launchd_database_dir, "jobcache.launchdata");
+ last_db_type = db_type;
+ break;
+ default :
+ break;
+ }
+
+ return result;
+}
int
_fd(int fd)
Modified: branches/PR-6564965/launchd/src/launchd.h
===================================================================
--- branches/PR-6564965/launchd/src/launchd.h 2009-02-28 21:16:59 UTC (rev 23850)
+++ branches/PR-6564965/launchd/src/launchd.h 2009-03-02 22:45:26 UTC (rev 23851)
@@ -35,7 +35,7 @@
extern bool g_force_old_kill_path;
extern bool g_simulate_pid1_crash;
extern FILE *g_console;
-extern char g_job_overrides_db_path[PATH_MAX];
+extern char g_launchd_database_dir[PATH_MAX];
bool init_check_pid(pid_t);
@@ -45,6 +45,13 @@
void launchd_single_user(void);
boolean_t launchd_mach_ipc_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);
+enum {
+ LAUNCHD_DB_TYPE_OVERRIDES,
+ LAUNCHD_DB_TYPE_JOBCACHE,
+ LAUNCHD_DB_TYPE_LAST,
+};
+char *launchd_data_base_path(int db_type);
+
void mach_start_shutdown(void);
int _fd(int fd);
Modified: branches/PR-6564965/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-6564965/launchd/src/launchd_core_logic.c 2009-02-28 21:16:59 UTC (rev 23850)
+++ branches/PR-6564965/launchd/src/launchd_core_logic.c 2009-03-02 22:45:26 UTC (rev 23851)
@@ -6867,7 +6867,7 @@
launch_data_free(output_obj);
break;
case VPROC_GSK_JOB_OVERRIDES_DB:
- if( !job_assumes(j, (output_obj = launch_data_new_string(g_job_overrides_db_path)) != NULL) ) {
+ if( !job_assumes(j, (output_obj = launch_data_new_string(launchd_data_base_path(LAUNCHD_DB_TYPE_OVERRIDES))) != NULL) ) {
goto out_bad;
}
packed_size = launch_data_pack(output_obj, (void *)*outval, *outvalCnt, NULL, NULL);
@@ -6877,6 +6877,17 @@
launch_data_free(output_obj);
break;
+ case VPROC_GSK_JOB_CACHE_DB:
+ if( !job_assumes(j, (output_obj = launch_data_new_string(launchd_data_base_path(LAUNCHD_DB_TYPE_JOBCACHE))) != NULL) ) {
+ goto out_bad;
+ }
+ packed_size = launch_data_pack(output_obj, (void *)*outval, *outvalCnt, NULL, NULL);
+ if (!job_assumes(j, packed_size != 0)) {
+ goto out_bad;
+ }
+
+ launch_data_free(output_obj);
+ break;
case 0:
mig_deallocate(*outval, *outvalCnt);
*outval = 0;
Modified: branches/PR-6564965/launchd/src/vproc_priv.h
===================================================================
--- branches/PR-6564965/launchd/src/vproc_priv.h 2009-02-28 21:16:59 UTC (rev 23850)
+++ branches/PR-6564965/launchd/src/vproc_priv.h 2009-03-02 22:45:26 UTC (rev 23851)
@@ -65,6 +65,7 @@
VPROC_GSK_PERUSER_SUSPEND,
VPROC_GSK_PERUSER_RESUME,
VPROC_GSK_JOB_OVERRIDES_DB,
+ VPROC_GSK_JOB_CACHE_DB,
} vproc_gsk_t;
typedef unsigned int vproc_flags_t;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090302/2851f21a/attachment.html>
More information about the launchd-changes
mailing list