mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-28 13:48:49 +08:00

* Use normalizer as stream source Renamed 'writer' service to 'normalizer' and dropped Cassandra facilities from it. Extracted the common dependencies to 'mainflux' package for easier sharing. Fixed the API docs and unified environment variables. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Use docker build arguments to specify build Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Remove cassandra libraries Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Update go-kit version to 0.6.0 Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix manager configuration Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Refactor docker-compose Merged individual compose files and dropped external links. Remove CoAP container since it is not referenced from NginX config at the moment. Update port mapping in compose and nginx.conf. Dropped bin scripts. Updated service documentation. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Drop content-type check Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Implement users data access layer in PostgreSQL Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Bump version to 0.1.0 Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Use go-kit logger everywhere (except CoAP) Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Improve factory methods naming Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Implement clients data access layer on PostgreSQL Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Make tests stateless All tests are refactored to use map-based table-driven tests. No cross-tests dependencies is present anymore. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Remove gitignore Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix nginx proxying Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Mark client-user FK explicit Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Update API documentation Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Update channel model Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Add channel PostgreSQL repository tests Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Implement PostgreSQL channels DAO Replaced update queries with raw SQL. Explicitly defined M2M table due to difficulties of ensuring the referential integrity through GORM. Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Expose connection endpoints Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix swagger docs and remove DB logging Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Fix nested query remarks Signed-off-by: Dejan Mijic <dejan@mainflux.com> * Add unique indices Signed-off-by: Dejan Mijic <dejan@mainflux.com>
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Functions to access/create device major and minor numbers matching the
|
|
// encoding used by the Linux kernel and glibc.
|
|
//
|
|
// The information below is extracted and adapted from bits/sysmacros.h in the
|
|
// glibc sources:
|
|
//
|
|
// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
|
|
// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
|
|
// number and m is a hex digit of the minor number. This is backward compatible
|
|
// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
|
|
// backward compatible with the Linux kernel, which for some architectures uses
|
|
// 32-bit dev_t, encoded as mmmM MMmm.
|
|
|
|
package unix
|
|
|
|
// Major returns the major component of a Linux device number.
|
|
func Major(dev uint64) uint32 {
|
|
major := uint32((dev & 0x00000000000fff00) >> 8)
|
|
major |= uint32((dev & 0xfffff00000000000) >> 32)
|
|
return major
|
|
}
|
|
|
|
// Minor returns the minor component of a Linux device number.
|
|
func Minor(dev uint64) uint32 {
|
|
minor := uint32((dev & 0x00000000000000ff) >> 0)
|
|
minor |= uint32((dev & 0x00000ffffff00000) >> 12)
|
|
return minor
|
|
}
|
|
|
|
// Mkdev returns a Linux device number generated from the given major and minor
|
|
// components.
|
|
func Mkdev(major, minor uint32) uint64 {
|
|
dev := (uint64(major) & 0x00000fff) << 8
|
|
dev |= (uint64(major) & 0xfffff000) << 32
|
|
dev |= (uint64(minor) & 0x000000ff) << 0
|
|
dev |= (uint64(minor) & 0xffffff00) << 12
|
|
return dev
|
|
}
|