~andersk/ubuntu/raring/kmod/lp1082598

« back to all changes in this revision

Viewing changes to libkmod/libkmod-util.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-09-21 16:05:32 UTC
  • mfrom: (4.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20120921160532-bdsxhmpj5og2ru5h
Tags: 9-2ubuntu1
* Sync with Debian unstable; remaining Ubuntu changes:
  - Ubuntu-specific depmod.d and modprobe.d contents.
  - Mark module-init-tools Multi-Arch: foreign.
  - Don't install Debian's extra/aliases.conf file.
  - Install upstart job instead of the sysvinit script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
        }
91
91
}
92
92
 
93
 
/*
94
 
 * Replace dashes with underscores.
95
 
 * Dashes inside character range patterns (e.g. [0-9]) are left unchanged.
96
 
 */
97
 
char *underscores(struct kmod_ctx *ctx, char *s)
98
 
{
99
 
        unsigned int i;
100
 
 
101
 
        if (!s)
102
 
                return NULL;
103
 
 
104
 
        for (i = 0; s[i]; i++) {
105
 
                switch (s[i]) {
106
 
                case '-':
107
 
                        s[i] = '_';
108
 
                        break;
109
 
 
110
 
                case ']':
111
 
                        INFO(ctx, "Unmatched bracket in %s\n", s);
112
 
                        break;
113
 
 
114
 
                case '[':
115
 
                        i += strcspn(&s[i], "]");
116
 
                        if (!s[i])
117
 
                                INFO(ctx, "Unmatched bracket in %s\n", s);
118
 
                        break;
119
 
                }
120
 
        }
121
 
        return s;
122
 
}
123
 
 
124
93
inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len)
125
94
{
126
95
        size_t s;
341
310
 
342
311
#define USEC_PER_SEC  1000000ULL
343
312
#define NSEC_PER_USEC 1000ULL
 
313
unsigned long long ts_usec(const struct timespec *ts)
 
314
{
 
315
        return (unsigned long long) ts->tv_sec * USEC_PER_SEC +
 
316
               (unsigned long long) ts->tv_nsec / NSEC_PER_USEC;
 
317
}
 
318
 
344
319
unsigned long long stat_mstamp(const struct stat *st)
345
320
{
346
321
#ifdef HAVE_STRUCT_STAT_ST_MTIM
347
 
        return (unsigned long long) st->st_mtim.tv_sec * USEC_PER_SEC +
348
 
               (unsigned long long) st->st_mtim.tv_nsec / NSEC_PER_USEC;
 
322
        return ts_usec(&st->st_mtim);
349
323
#else
350
324
        return (unsigned long long) st->st_mtime;
351
325
#endif