~ubuntu-branches/ubuntu/trusty/thermald/trusty-updates

« back to all changes in this revision

Viewing changes to src/thd_sys_fs.cpp

  • Committer: Package Import Robot
  • Author(s): Colin King
  • Date: 2014-02-11 08:06:33 UTC
  • Revision ID: package-import@ubuntu.com-20140211080633-l5yxajfiwcd4kin2
Tags: 1.1~rc2-7
* Redirect fd 0, 1, 2 to /dev/null to stop poll() spinning (Closes: #737093)
* Add upstream commit; Prevent exception for invalid sysfs file reads

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        return ret;
123
123
}
124
124
 
 
125
int csys_fs::read(const std::string &path, unsigned long *ptr_val) {
 
126
        std::string p = base_path + path;
 
127
        char str[32];
 
128
        int ret;
 
129
 
 
130
        int fd = ::open(p.c_str(), O_RDONLY);
 
131
        if (fd < 0) {
 
132
                thd_log_warn("sysfs read failed %s\n", path.c_str());
 
133
                return -errno;
 
134
        }
 
135
        ret = ::read(fd, str, sizeof(str));
 
136
        if (ret > 0)
 
137
                *ptr_val = atol(str);
 
138
        else
 
139
                thd_log_warn("sysfs read failed %s\n", path.c_str());
 
140
        close(fd);
 
141
 
 
142
        return ret;
 
143
}
 
144
 
125
145
int csys_fs::read(const std::string &path, std::string &buf) {
126
146
        std::string p = base_path + path;
127
147